Differences From Artifact [ccaa08b8db]:
- File src/OFThread.h — part of check-in [c7f0229795] at 2020-01-02 01:51:34 on branch trunk — Update copyright (user: js, size: 7858) [annotate] [blame] [check-ins using] [more...]
To Artifact [4c0a8350b3]:
- File
src/OFThread.h
— part of check-in
[e7f4f80e23]
at
2020-01-24 03:03:32
on branch trunk
— runtime: Correctly handle AR pool push during pop
Getting a pointer and increasing it until we reach the top pointer does
not work: Releasing an object can temporarily create new autorelease
pools, which can trigger resizing of "objects" using realloc, which can
move it to a different address, which will then lead to continuing to
iterate on a now invalid pointer.This is now solved by using an index into "objects" instead. Since we're
now indexing for the pop, let's use indexes everywhere, as they're more
readable anyway.While debugging this, I noticed that the last pool is popped quite
frequently, only for a new pool to be pushed immediately again. This
resulted in a free followed by a malloc every time. Instead, keep the
pool, but let OFThread explicitly say when to free everything. (user: js, size: 7892) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | of_thread_t _thread; of_thread_attr_t _attr; enum of_thread_running { OF_THREAD_NOT_RUNNING, OF_THREAD_RUNNING, OF_THREAD_WAITING_FOR_JOIN } _running; void *_pool; # ifdef OF_HAVE_BLOCKS of_thread_block_t _Nullable _threadBlock; # endif jmp_buf _exitEnv; id _returnValue; bool _supportsSockets; OFRunLoop *_Nullable _runLoop; | > > | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | of_thread_t _thread; of_thread_attr_t _attr; enum of_thread_running { OF_THREAD_NOT_RUNNING, OF_THREAD_RUNNING, OF_THREAD_WAITING_FOR_JOIN } _running; # ifndef OF_OBJFW_RUNTIME void *_pool; # endif # ifdef OF_HAVE_BLOCKS of_thread_block_t _Nullable _threadBlock; # endif jmp_buf _exitEnv; id _returnValue; bool _supportsSockets; OFRunLoop *_Nullable _runLoop; |
︙ | ︙ |