ObjFW  View Ticket

2020-11-12
00:34 Fixed ticket [5b31b3f45e]: Weak references are broken with the Apple runtime plus 4 other changes artifact: 865fcafc00 user: js
2020-11-01
09:15 Ticket [62fe928cfb] Have tests for ARC status still Open with 4 other changes artifact: 766dce1650 user: js
2020-10-25
22:10 Ticket [5b31b3f45e] Weak references are broken with the Apple runtime status still Open with 3 other changes artifact: c0cb482c58 user: js
21:09 Ticket [5b31b3f45e]: 4 changes artifact: 5309f065e7 user: js
21:09 New ticket [5b31b3f45e]. artifact: 9266591019 user: js

Ticket UUID: 5b31b3f45e9a8150eef903081594e04beea8f4f5
Title: Weak references are broken with the Apple runtime
Status: Fixed Type: Code_Defect
Severity: Severe Priority: Immediate
Subsystem: Resolution: Fixed
Last Modified: 2020-11-12 00:34:04
Version Found In: Milestone: 1.0
User Comments:
js added on 2020-10-25 21:09:05:

The Apple runtime seems to make some assumptions about root objects being NSObject, and as a result segfaults when using weak.


js added on 2020-10-25 22:10:52:

Looking at the code, it seems that objc_destructInstance() does not zero weak references at all in the Apple runtime. It seems to make weak references work at all, it is necessary to call into the runtime functions to allocate, retain, release and dealloc objects. Unfortunately, this does not allow to have some extra space before the object, as the current +[alloc] does for memory blocks belonging to the object.


js added on 2020-11-12 00:34:04:

Turns out the configure check for objc_constructInstance was broken, and hence runtime/instance.m was used for objc_destructInstance instead of the runtime's, resulting in weak references not being handled on dealloc.

Fixed in [4c16806252].