Wednesday, February 12, 2020

KVO Reentrancy Canary

Ilya Kulakov (tweet):

While possibility of race conditions in the multithreaded code is a side effect of the desired behavior when multiple processing units compute result based on the shared data, Same-Stack Race Conditions are outright incorrect.

KVO, while often a hated victim, is not the only troubled technology. Everything that uses same-stack callbacks, including Delegates and Notifications, is susceptible.

[…]

In Objective-C and Cocoa I use the following lock-like approach that relies on RAII scopes (and relatively “modern” Clang and GCC that support the cleanup attribute) to detect the errors[…]

Previously:

Comments RSS · Twitter

Leave a Comment