News for hackers. Stuff that matters.
Re:Concurrent Memory Deallocation in the Objective-C Runtime by vitalyd on Saturday June 06, 2015 @11:53PM (#9673332)
This is both clever and terrifying :). How do they prevent compiler from scheduling the load early, observing, and using the stale cache pointer? Do they have at least a compiler fence on the read side?
Re:Concurrent Memory Deallocation in the Objective-C Runtime by bdonlan on Sunday June 07, 2015 @06:17AM (#9674057)
The read-side code in question is hand-written assembly code, isn't it? And on the hardware side, observing pc will probably result in an actual memory barrier happening anyway (even if no signal is sent internally the kernel must still suspend the thread to capture register state, and then it needs a barrier to communicate that result back to the asking thread).
Re:Concurrent Memory Deallocation in the Objective-C Runtime by vitalyd on Sunday June 07, 2015 @09:13AM (#9674520)
Yes, perhaps that part is in the hand written assembly portion that's mentioned.
Re:Concurrent Memory Deallocation in the Objective-C Runtime by ridiculous_fish on Sunday June 07, 2015 @04:08AM (#9673817)
Nothing prevents using a stale cache pointer. The stale cache still contains correct data, so using it is benign, up until it gets deallocated.

A stale cache pointer may become wrong if a method implementation is replaced, e.g. by a category, but replacing a method while calling it in another thread is inherently racey.

Re:Concurrent Memory Deallocation in the Objective-C Runtime by vitalyd on Sunday June 07, 2015 @09:05AM (#9674499)
By stale I meant holding a ref to a cache about to be deleted.