Approachable Concurrency flag = YES corrupts actor asyc function parameters

I have an existing project that has a network data service actor.
This actor contains a list of async fetching from backend functions.
One of the function is like:

func fetchNewsList(userID: Int64, pageID: Int32, pageSize: Int32) async throws -> [News] { ... }

My view model calls this function and it is working fine until I set Approachable Concurrency to yes.
I find the parameter values passed into the fetchNewsList function is changed to some other values, which then caused backend errors.

I inspect the value changes, before entering the fetchNewsList:

  • userID: 199
  • pageID: 1
  • pageSize: 10

right after entering the fetchNewsList():

  • userID: 10243484928
  • pageID: 1565315120
  • pageSize: 199

From my experience, this is normally caused by ABI mismatch.
But I cleaned the build folder a few times, still got the same problem.
By observing the corrupted values, I have a feeling values are shifted by some new hidden parameters. Can it be the current executor? I don't know.

Setting the flag to No or mark the function with nonisolated fixes the problem immediately.

Another thing to mention is I have no compile error after setting the flag to Yes and my Default Actor Isolation is set to nonisolated the entire time.

1 Like

For bugs like these it's best if you can provide a small reproducer (swiftpm package or single file even) and file an issue on GitHub - swiftlang/swift: The Swift Programming Language

Definitely sounds like something we should check.

Which exact version of Xcode/swift is this happening on?

As @ktoso said... we really need a reproducer of some sort to dig into. If you can provide that to us... we can figure this out pretty quick.