how to open elf file image from inside genode? libbacktrace question

Alexander Tormasov a.tormasov at innopolis.ru
Mon Apr 12 01:38:59 CEST 2021


Hello Josef,
I apply patch and remove some ld_verbose options from run file (to allow it to work), and got another interesting backtrace during unwind attempt, see below.
In short, it try to open ld.lib.so (from inside genode), open() fail, and it try to obtain libc errno (via jmp_slot/etc from shared library).
So, this is inside dl_iterate_phdr under mutex, as usual, and double mutex call related to search of errno.
I suspect other potential code path where we can hit «seach for address of some functions from shared libraries»... 

Finally I will remove, as suggested , mutex guard from dl_iterate_phdr completely - while not so sure that this will not lead to error.
Also I add the following to the run file to allow read of ld.lib.so from inside (not sure that this is correct - may be need something else? like direct reference to rom session?)
                    <dir name=«ld.lib.so»> </dir>

Seems that after that operation my SMP small test with even 4 CPU works somehow (need more extensive tests to be run for golang and goroutunes).

Question: how to verify that removed mutex call does not break something important?

#0 __error () at /var/services/homes/admin/gen/21.02/repos/libports/src/lib/libc/errno.cc:20
#1 0x0000000010f80a16 in Libc::Vfs_plugin::stat (this=<optimized out>, path=<optimized out>, buf=<optimized out>) at /var/services/homes/admin/gen/21.02/repos/libports/src/lib/libc/vfs_plugin.cc:809
#2 0x0000000010f2f07e in Libc::resolve_symlinks (path=<optimized out>, resolved_path=...) at /var/services/homes/admin/gen/21.02/repos/os/include/os/path.h:239
#3 0x0000000010f30cbb in __sys_open (pathname=0x161380 <Linker::Ld::linker()::_linker+32> "ld.lib.so", flags=0x100000) at /var/services/homes/admin/gen/21.02/repos/os/include/os/path.h:239
#4 0x000000000119aa56 in backtrace_open (filename=0x161380 <Linker::Ld::linker()::_linker+32> "ld.lib.so", error_callback=0x1198503 <error_callback>, data=0x405fe770, does_not_exist=0x405fe1c4) at /var/services/homes/admin/gen/21.02/contrib/libbacktrace-cabcd83bc903137f607eda3a65eb09feaa5f507e/src/lib/gcc/libbacktrace/posix.c:67
#5  0x000000000119fd00 in phdr_callback (info=0x405fe200, size=0x20, pdata=0x405fe290) at /var/services/homes/admin/gen/21.02/contrib/libbacktrace-cabcd83bc903137f607eda3a65eb09feaa5f507e/src/lib/gcc/libbacktrace/elf.c:3264
#6  0x00000000000ebe6e in dl_iterate_phdr (callback=0x119fc27 <phdr_callback>, data=0x405fe290) at /var/services/homes/admin/gen/21.02/repos/base/src/lib/ldso/exception.cc:53
#7  0x000000000119fe7a in backtrace_initialize (state=0x29000, filename=0x126d0c6 "/proc/self/exe", descriptor=0x3, error_callback=0x1198503 <error_callback>, data=0x405fe770, fileline_fn=0x405fe370) at /var/services/homes/admin/gen/21.02/contrib/libbacktrace-cabcd83bc903137f607eda3a65eb09feaa5f507e/src/lib/gcc/libbacktrace/elf.c:3313
#8  0x000000000119a8c1 in fileline_initialize (state=0x29000, error_callback=0x1198503 <error_callback>, data=0x405fe770) at /var/services/homes/admin/gen/21.02/contrib/libbacktrace-cabcd83bc903137f607eda3a65eb09feaa5f507e/src/lib/gcc/libbacktrace/fileline.c:143
#9  0x000000000119a965 in backtrace_pcinfo (state=0x29000, pc=0x11985d0, callback=0x119804e <callback>, error_callback=0x1198503 <error_callback>, data=0x405fe770) at /var/services/homes/admin/gen/21.02/contrib/libbacktrace-cabcd83bc903137f607eda3a65eb09feaa5f507e/src/lib/gcc/libbacktrace/fileline.c:177
#10 0x000000000119ac8c in unwind (context=0x405fe420, vdata=0x405fe700) at /var/services/homes/admin/gen/21.02/contrib/libbacktrace-cabcd83bc903137f607eda3a65eb09feaa5f507e/src/lib/gcc/libbacktrace/backtrace.c:91
#11 0x00000000000d7179 in _Unwind_Backtrace (trace=0x119abbc <unwind>, trace_argument=0x405fe700) at /genodelabs-genode-2491eee/contrib/gcc-3cade18cf9defeefa714aa91de3b157fbad4aa18/src/noux-pkg/gcc/libgcc/unwind.inc:307
#12 0x000000000119ad62 in backtrace_full (state=0x29000, skip=0x0, callback=0x119804e <callback>, error_callback=0x1198503 <error_callback>, data=0x405fe770) at /var/services/homes/admin/gen/21.02/contrib/libbacktrace-cabcd83bc903137f607eda3a65eb09feaa5f507e/src/lib/gcc/libbacktrace/backtrace.c:127
#13 0x00000000011985d1 in runtime_callers (skip=0x2, locbuf=0xc4200148d8, m=0x20, keep_thunks=0x0) at /var/services/homes/admin/gen/21.02/contrib/libgo-281260d9bdc27fefb62c00310025c54e1e629a2e/src/lib/gcc/libgo/runtime/go-callers.c:207


More information about the users mailing list