* Jeff Law: > Something like setup a signal handler when we first start unwinding that > flags the error and tear it down when we're done unwinding? Obviously > we can't do setup/tear down each time for each address. Anyway, just > thinking outloud here...
Linux doesn't have per-thread signal handlers, so this doesn't work reliably. If speed is not a concern, but reliability is, call fork (the system call, not glibc's wrapper which calls fork handlers) and do the work in a single-threaded copy of the process. There, you can set up signal handlers as you see fit, and the VM layout won't change unexpectedly. A completely different way to deal with this is to have the shell and abrt/apport/systemd-coredumpd coordinate and generate the backtrace from a userspace coredump handler. To harden unwinding against corrupted tables or table locations, we'd have to change ld.so to make all critical data read-only after loading and remove the unwinder caches (with more help from ld.so instead). It would make sense to move the unwinder implementation into ld.so. With proper hardening, corrupted stacks would not be able to cause crashes anymore, either.