This is the mail archive of the mailing list for the elfutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Fix corruption of non-C++ symbols by the demangler

On Mon, 2014-01-13 at 23:17 +0100, Jan Kratochvil wrote:
> for example currently plain symbol "f" (for function f()) gets printed in the
> backtrace as "float" (as for a function float()).

Nice catch.

> I am not completely sure about DCT_GLOBAL_CTORS and DCT_GLOBAL_DTORS but I
> could not find a compliant symbol without leading _Z for it.

The __GLOBAL__.[ID]_xxx functions are wrappers generated when a module
xxx contains constructors and destructors of static objects, which will
call the actual static initialization and destruction functions for all
globals in the module. Since they are "normal" functions they could
potentially end up in a backtrace, but I am not sure "demangling" them
provides any real benefit.

> DCT_TYPE is apparently inappropriate for the unwinder.

Indeed. That is what gets demangled with c++filt --types (demangle type
encodings). Which is not done normally by default in c++filt. I wasn't
aware __cxa_demangle does do that by default. Just checking that the
name starts with _Z is probably the right thing to do.

> commit e1b6b9d3131f32ef54932388c814adc02ca6a329
> Author: Jan Kratochvil <>
> Date:   Mon Jan 13 23:04:03 2014 +0100
>     Fix corruption of non-C++ symbols by the demangler.
>     ./
>     2014-01-13  Jan Kratochvil  <>
>     	* Add AC_PROG_CXX.

Till now we didn't require a C++ compiler explicitly. I am not against
it, we will one day anyway. But it might be simpler to just add the
generated exe and core as done with other tests. And just test with
--executable --core. It makes sure we don't rely on any particular
compiler version for the test data.

>     src/
>     2014-01-13  Jan Kratochvil  <>
>     	* stack.c (print_frames) <USE_DEMANGLE>: Check for _Z.

The other user of __cxa_demangle nm.c (show_symbols_sysv) probably needs
the same check.

>     tests/
>     2014-01-13  Jan Kratochvil  <>
>     	* (check_PROGRAMS): Add backtrace-demangle.
>     	(TESTS): Add
>     	(EXTRA_DIST): Add
>     	(backtrace_demangle_SOURCES): New.
>     	* New file.
>     	* New file.
> +endif

A slightly simpler way to handle this is to not unconditionally add
backtrace-demangle to check_PROGRAMS and to
TESTS, but only if we have the demangler (which probably also indicates
we actually have a C++ compiler, so we don't even try to compile it

check_programs += backtrace-demangle



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]