[PATCH 4/5] Support backtracing through elfutils (#70746)

Jan Kratochvil jan.kratochvil at redhat.com
Thu Oct 31 15:39:18 CET 2013


On Thu, 31 Oct 2013 11:28:14 +0100, Jan Kratochvil wrote:
> Calling backtrace() for the first time also is not signal-safe:
> glibc/sysdeps/x86_64/backtrace.c init() calls __libc_dlopen().
> Maybe xorg could call backtrace() just during init to get backtrace()
> initialized, I am not completely sure it will be signal-safe then but it may be.

That initialization is already done in xserver as shown by Adam Jackson:
	http://cgit.freedesktop.org/xorg/xserver/commit/?id=0b131a5cd91cea54240777c66a9cd385029e8cb2


> To get .symtab symbols resolution the only safe way is to do fork()+exec().

Surprisingly libunwind is mostly signal-safe, similarly like backtrace() is.
As pointer out by Jakub Jelinek, they are not completely safe wrt
_dl_load_lock dependency of dl_iterate_phdr() which is used by both.
But that should not matter too much in practice for xserver.

I would still find safer to run external backtracer via fork()+exec() than
doing the whole backtrace from SIGSEGV handler, for example due to memory
corruption inside xserver.

That is without fork()+exec() libunwind is currently the best there is for
xserver.


Jan


More information about the xorg-devel mailing list