On May 24 2011, FX wrote:
One solution could be to search the PATH for addr2line during library
initialization (where we don't need to be async-signal-safe), and then
store it somewhere and use it in show_backtrace().
That's one way. Another way is just to store a copy of the PATH during
initialization, and only search addr2line when really needed (which can
be done with a static buffer and a series of call to execve(), can't it?)
Well, yes, but it is better design to do as little as possible in such
handlers. No matter what POSIX says, calling fork or exec is intrinsically
problematic - for example, ANY signal (including SIGCONT!) can cause
chaos if it is received in such circumstances, and the actual rules for
which processes get which signals are foul beyond belief, even when the
term 'rules' makes sense :-(
That favours Janne's approach.
Regards,
Nick Maclaren.