-
Notifications
You must be signed in to change notification settings - Fork 32
Description
The initialization of liballocs has always been fragile. It often suffers reentrancy problems, e.g. from early malloc calls in the ld.so. We have ways of dealing with these case-by-case, but it's not very satisfactory. At present, the ld.so always runs before we do, so we are always at its mercy. We already have a certain amount of complexity for bringing ourselves up during normal DSO construction, e.g. allowing for the span where systrapping is not enabled. Recent glibc bug workaround efforts (#81) are an especially nasty case of this.
The addition of allocsld allows us to change that. I am in the process of a basic version of binary instrumentation of allocation functions (#11). Combining these two, we may be able to introspect on the whole of execution much more uniformly, starting from the ld.so or even from allocsld itself, and seeing all mmap calls from the off. (The only code in allocsld that needs to be runnable after it jumps to the real ld.so is the _dl_debug_state function. We could put that on a separate page, even, so that none of the other code retains execute permission.)
Of course there is a meta-completeness issue (#16). Binary instrumentation complicates this because it involves allocating trampolines that currently have no meta-information of their own and break backtraces. This is fixable, however.
I'm vaguely imagining a simplified initialization where
- all mmaps are caught uniformly (but by what code? it may need to be duplicated in allocsld)
- liballocs would ideally need no constructor at all (but how is this different from allocsld just being liballocs? I think I considered and rejected that in Dummyweaks library should go away #56)