swift icon indicating copy to clipboard operation
swift copied to clipboard

Improve dynamic actor isolation diagnostics

Open hborla opened this issue 1 year ago • 1 comments

Motivation

Today, the actor isolation diagnostics are pretty confusing, especially if they come from a custom executor, which does not have as much information as the concurrency runtime about what isolation was expected. The concurrency runtime function could also accept more parameters to allow the compiler to feed through information from the type checker, such as why the expected isolation is what it is (e.g. it could have been inferred). The runtime diagnostic also does not offer any sort of solution, despite several workarounds existing.

Proposed solution

The runtime diagnostic should always state what the expected isolation was, it should give a reason for the expected isolation, and it should offer actionable guidance on how to resolve the issue.

Alternatives considered

No response

Additional information

No response

hborla avatar Jul 26 '24 16:07 hborla

@ktoso is starting to build a general runtime entry point to support this in https://github.com/swiftlang/swift/pull/75200

hborla avatar Jul 26 '24 16:07 hborla

The concurrency runtime function could also accept more parameters to allow the compiler to feed through information from the type checker, such as why the expected isolation is what it is

I added this information to the result of ActorIsolationRequest in https://github.com/swiftlang/swift/pull/75668, which could be used to form the diagnostic argument when emitting the dynamic isolation check in SILGen.

hborla avatar Aug 14 '24 19:08 hborla

Definitely agree here that the messaging around this feature needs to be improved.

We started seeing crashes related to dynamic actor isolation in Xcode 16.3's toolchain (we had enabled dynamic actor isolation some time before that) and had no idea what was happening or why it was crashing.

I have a sample project to easily cause a dynamic actor isolation crash if its helpful:

Crash test.zip

BrentMifsud avatar Jun 11 '25 21:06 BrentMifsud