antrax
05/16/2019, 11:15 AMrusshwolf
05/16/2019, 11:43 AMkpgalligan
05/16/2019, 1:16 PMkpgalligan
05/16/2019, 1:18 PMkpgalligan
05/16/2019, 1:20 PMkpgalligan
05/16/2019, 1:21 PMkpgalligan
05/16/2019, 1:24 PMkpgalligan
05/16/2019, 1:28 PMolonho
05/16/2019, 3:29 PMolonho
05/16/2019, 3:30 PMkpgalligan
05/16/2019, 4:19 PMantrax
05/16/2019, 11:57 PMolonho
05/17/2019, 5:23 AMkpgalligan
05/17/2019, 2:14 PMkpgalligan
05/17/2019, 2:24 PMantrax
05/17/2019, 3:38 PMantrax
05/17/2019, 3:40 PMkpgalligan
05/17/2019, 3:54 PMkpgalligan
05/17/2019, 3:55 PMkpgalligan
05/17/2019, 3:55 PMkpgalligan
05/17/2019, 3:55 PMsomeData
after you pass it to execute
, so it can be unsafe, right? Nope.kpgalligan
05/17/2019, 4:06 PMcrashy
ends, the runtime subtracts 1 on the ref count for someData
, but it’s possible that the worker has started, which means 2 threads may be modifying the ref count. Non-sharable data does non-atomic ref counting, so you can wind up deallocating data you’re still referencing.kpgalligan
05/17/2019, 4:08 PMPaul Idstein
05/17/2019, 4:51 PMkpgalligan
05/17/2019, 5:13 PMkpgalligan
05/17/2019, 5:19 PMPaul Idstein
05/17/2019, 5:59 PMPaul Idstein
05/17/2019, 6:08 PMantrax
05/17/2019, 6:37 PMkpgalligan
05/17/2019, 7:50 PMkpgalligan
05/17/2019, 7:51 PMkpgalligan
05/17/2019, 7:51 PMkpgalligan
05/17/2019, 7:55 PMkpgalligan
05/17/2019, 7:56 PMantrax
05/17/2019, 8:16 PMkpgalligan
05/17/2019, 9:26 PMkpgalligan
05/17/2019, 9:28 PMsvyatoslav.scherbina
05/20/2019, 8:51 AMStableRef looks like a promising workaround. It hides a shared data from K/N ARC (so no concurrent access to the ref count) and allows to mutate it from a worker.It is not supposed to work that way. Unfrozen objects are bound to their threads until explicitly transferred using corresponding APIs.
StableRef
will likely have proper checks and forbid such an abuse with accessing from wrong thread.antrax
05/20/2019, 3:56 PMsvyatoslav.scherbina
05/20/2019, 4:05 PMkpgalligan
05/20/2019, 4:10 PMkpgalligan
05/20/2019, 4:11 PM