Repository navigation
Conversation
|
Thanks. That's an embarrassing bug. The fix isn't quite correct. Trampoline sets are supposed to be kept in a list (with each node having an inline free list). Setting the head of the list to NULL when you allocate a new node will cause a memory leak (and cause We probably need a test that sets and unsets a few thousand blocks as IMPs. |
|
(CI failures are unrelated, they appear to be due to the ubuntu-latest image moving forward and needing a newer cross-libstdc++) |
I hit the same limit while porting a library that swizzles methods with block IMPs, and opened #439 with a fix along these lines. When every set is full, the new set is linked in at the head of the list and the older sets stay in it, each with its own free list. Nothing leaks, and trampolines freed in any set get reused.
#439 adds The tests also turned up a few smaller bugs, fixed in the same PR:
|
The current implementation crashes after a single page of trampolines for imp_implementationWithBlock() is exhausted, on ARM64 that is after 127 invocations of imp_implementationWithBlock().
This patch checks if trampolines are exhausted and resets the trampoline ptr to NULL, triggering a new allocation.