gnustep / libobjc2

Objective-C runtime library intended for use with Clang.
http://www.gnustep.org/
MIT License
426 stars 116 forks source link

Fix lock-ordering during init #237

Closed ERobsham closed 1 year ago

ERobsham commented 1 year ago

Reorders how locking is handled in objc_send_initialize() to prevent a deadlock. Previously, contention on the low level spinlocks could cause a very intermittent deadlock:

davidchisnall commented 1 year ago

Thanks, I think we need to keep the current lock acquisition to avoid UB but then drop it before acquiring the second one and reacquire it lower down.

ERobsham commented 1 year ago

Thanks for the speedy response! Im not 100% sure what you mean by "to avoid UB"? So let me know if this update was the correct change you're looking for.

davidchisnall commented 1 year ago

Looks great, thanks!