Fix: race conditions in DefaultNetworkService.lookup by removing async from AttachmentAllocator.lookup#1699
Conversation
…ace conditions because the deallocator being called while lookup is running as it overrides the actor's reentrancy protection
|
Hi @GarySkywalker-droid could you describe the race condition this change fixes a bit more? I'm not clear where the issue is |
kiwigitops
left a comment
There was a problem hiding this comment.
I think this still needs an await at the call site. Even if lookup(hostname:) is no longer declared async, AttachmentAllocator is an actor, and this call is still crossing from DefaultNetworkService to a different actor instance. Swift treats that as an asynchronous actor-isolated access, so try allocator.lookup(hostname:) should not compile as written.
That also means this change may not remove the suspension point the PR is trying to avoid. The race probably needs a different shape, such as performing the hostname lookup inside the allocator operation that owns the related state transition, or otherwise avoiding a separate cross-actor read.
Type of Change
Motivation and Context
Removed the async from AttachmentAllocator.lookup, causing the race conditions because the deallocator being called while lookup is running as it overrides the actor's reentrancy protection. Leading to at times mac address being returned as nil and fixes the #1693
Testing