Hitting g dwfl->lookup_elts limit in report_r_debug, so not all modules show up and backtracing fails

Florian Weimer fweimer@redhat.com
Tue May 2 07:57:59 GMT 2023

* Luke Diamand via Elfutils-devel:

> I've got a few cores where report_r_debug() in link_map.c fails to
> find all of the modules - for example I had libc.so missing. This
> obviously meant that elfutils could not backtrace my core.
> It seems to be related to this code:
>   /* There can't be more elements in the link_map list than there are
>      segments.  DWFL->lookup_elts is probably twice that number, so it
>      is certainly above the upper bound.  If we iterate too many times,
>      there must be a loop in the pointers due to link_map clobberation.  */
>   size_t iterations = 0;
>   while (next != 0 && ++iterations < dwfl->lookup_elts)
> I've changed this to just keep going until it reaches
> dwfl->lookup_elts*5, which seems to "fix" it, but I feel there must be
> a better fix!
> The most recent core I saw with this had lookup_elts=36, and hit 109
> iterations of the loop and then backtraced just fine.

It's probably another fallout from -z separate-code, which tends to
create four LOAD segments.  The magic number 5 sounds about right, as
gold also has -z text-unlikely-segment, which might result in creating
that number of load segments (but I haven't tried).


More information about the Elfutils-devel mailing list