Skip to content

Compute backend crashes during repeated dynamic view updates #2

Open
jcmosc/Compute
#86

Description

@Kyle-Ye

Description

Game2048 crashes after repeated moves when OpenSwiftUI uses the Compute backend. The crash occurs on both macOS and iOS. The AttributeGraph backend does not reproduce the issue.

Reproduction

Example: OpenSwiftUIProject/Game2048, revision 046aecb.

Configuration

  • Game2048: 046aecb
  • OpenSwiftUI: 8362d9bb
  • Compute: 0.6.4, commit e652ec1
  • Game2048 environment: osui-source,compute,local

Steps to reproduce

  1. Generate Game2048 with the configuration above.
  2. Run Game2048App on macOS or an iOS Simulator.
  3. Make repeated moves in different directions.

The crash occurs after multiple moves, rather than on the first move.

Actual behavior

The app crashes in objc_retain while accessing a subgraph:

// DynamicContainerInfo.updateValue()
info.items[target].subgraph.index = UInt32(index)

Zombie diagnostics confirm that the subgraph has already been deallocated.

Root cause

Compute uses a custom vector with an inline capacity of 32 for the subgraph traversal stack.

When the stack exceeds that capacity, the vector relocates its elements to heap storage. However, its inline storage is a regular C++ array, so the array elements are also destroyed when the vector is destroyed. The stale inline copies release subgraph references again, which can deallocate subgraphs that still have owners.

Proposed fix

Use inline storage with explicit element lifetime management so that relocated elements are not destroyed again.

A regression test with 64 child subgraphs fails with SIGSEGV before the fix and passes afterward.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions