This is an archive of the discontinued LLVM Phabricator instance.

[libunwind] Fix usage of `_dl_find_object` on 32-bit x86
ClosedPublic

Authored by avogelsgesang on Sep 14 2022, 3:42 AM.

Details

Summary

On 32-bit x86, _dl_find_object also returns a dlfo_eh_dbase address.
So far, compiling against a version of _dl_find_object which returns a
dlfo_eh_dbase was blocked using a #if + #error. This commit now
removes this compile time assertion and simply ignores the returned
dlfo_eh_dbase. All test cases are passing on a 32-bit build now.

According to https://www.gnu.org/software/libc/manual/html_node/Dynamic-Linker-Introspection.html,
dlfo_eh_dbase should be the base address for all DW_EH_PE_datarel
relocations. However, glibc/elf/dl-find_object.h says that eh_dbase
is the relocated DT_PLTGOT value. I don't understand how those two
statements fit together, but to fix 32-bit x86, ignoring dlfo_eh_dbase
seems to be good enough.

Fixes #57733

Diff Detail

Event Timeline

avogelsgesang created this revision.Sep 14 2022, 3:42 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptSep 14 2022, 3:42 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
avogelsgesang requested review of this revision.Sep 14 2022, 3:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 14 2022, 3:42 AM
mgorny added a subscriber: mgorny.Sep 14 2022, 5:43 AM

Well, this fixes the build failure but now half of the tests fail:

lit: /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libcxx/utils/libcxx/test/newconfig.py:19: note: (llvm-libunwind-shared.cfg.in) Using %{cxx} substitution: '/usr/lib/ccache/bin/i686-pc-linux-gnu-clang++'
lit: /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libcxx/utils/libcxx/test/newconfig.py:19: note: (llvm-libunwind-shared.cfg.in) Using %{flags} substitution: ' --target=i686-pc-linux-gnu'
lit: /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libcxx/utils/libcxx/test/newconfig.py:19: note: (llvm-libunwind-shared.cfg.in) Using %{compile_flags} substitution: '-nostdinc++ -I %{include} -funwind-tables -std=c++2b -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings'
lit: /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libcxx/utils/libcxx/test/newconfig.py:19: note: (llvm-libunwind-shared.cfg.in) Using %{link_flags} substitution: '-L %{lib} -Wl,-rpath,%{lib} -lunwind -ldl -Wl,--export-dynamic'
lit: /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libcxx/utils/libcxx/test/newconfig.py:19: note: (llvm-libunwind-shared.cfg.in) Using %{exec} substitution: '%{executor} --execdir %T -- '
lit: /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libcxx/utils/libcxx/test/newconfig.py:19: note: (llvm-libunwind-shared.cfg.in) All available features: thread-safety, c++2b, linux, fcoroutines-ts, clang, clang-16.0.0, has-unix-headers, stdlib=llvm-libc++, clang-16.0, buildhost=linux, clang-16, glibc-old-ru_RU-decimal-point, locale.en_US.UTF-8, diagnose-if-support, objective-c++, host-has-gdb-with-python, stdlib=libc++, target=i686-pc-linux-gnu, libcpp-has-no-incomplete-format, verify-support, -fsized-deallocation, fdelayed-template-parsing, long_tests, has-fblocks, -faligned-allocation, has-clang-query, has-fconstexpr-steps, has-clang-tidy
-- Testing: 12 tests, 12 workers --
UNSUPPORTED: llvm-libunwind-shared.cfg.in :: floatregister.pass.cpp (1 of 12)
UNSUPPORTED: llvm-libunwind-shared.cfg.in :: bad_unwind_info.pass.cpp (2 of 12)
UNSUPPORTED: llvm-libunwind-shared.cfg.in :: remember_state_leak.pass.sh.s (3 of 12)
UNSUPPORTED: llvm-libunwind-shared.cfg.in :: unwind_leaffunction.pass.cpp (4 of 12)
UNSUPPORTED: llvm-libunwind-shared.cfg.in :: signal_unwind.pass.cpp (5 of 12)
PASS: llvm-libunwind-shared.cfg.in :: alignment.compile.pass.cpp (6 of 12)
PASS: llvm-libunwind-shared.cfg.in :: unw_getcontext.pass.cpp (7 of 12)
PASS: llvm-libunwind-shared.cfg.in :: frameheadercache_test.pass.cpp (8 of 12)
FAIL: llvm-libunwind-shared.cfg.in :: libunwind_01.pass.cpp (9 of 12)
******************** TEST 'llvm-libunwind-shared.cfg.in :: libunwind_01.pass.cpp' FAILED ********************
Script:
--
: 'COMPILED WITH';  /usr/lib/ccache/bin/i686-pc-linux-gnu-clang++ /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/test/libunwind_01.pass.cpp  --target=i686-pc-linux-gnu -nostdinc++ -I /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/include -funwind-tables -std=c++2b -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings  -L /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/lib -Wl,-rpath,/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/lib -lunwind -ldl -Wl,--export-dynamic -o /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/libunwind_01.pass.cpp.dir/t.tmp.exe
: 'EXECUTED AS';  /usr/bin/python3.11 /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libcxx/utils/run.py --execdir /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/libunwind_01.pass.cpp.dir --  /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/libunwind_01.pass.cpp.dir/t.tmp.exe
--
Exit Code: 250

Command Output (stdout):
--
$ ":" "COMPILED WITH"
$ "/usr/lib/ccache/bin/i686-pc-linux-gnu-clang++" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/test/libunwind_01.pass.cpp" "--target=i686-pc-linux-gnu" "-nostdinc++" "-I" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/include" "-funwind-tables" "-std=c++2b" "-Werror" "-Wall" "-Wextra" "-Wshadow" "-Wundef" "-Wno-unused-command-line-argument" "-Wno-attributes" "-Wno-pessimizing-move" "-Wno-c++11-extensions" "-Wno-noexcept-type" "-Wno-atomic-alignment" "-Wno-user-defined-literals" "-Wno-tautological-compare" "-Wsign-compare" "-Wunused-variable" "-Wunused-parameter" "-Wunreachable-code" "-Wno-unused-local-typedef" "-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER" "-D_LIBCPP_DISABLE_AVAILABILITY" "-fcoroutines-ts" "-Werror=thread-safety" "-Wuser-defined-warnings" "-L" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/lib" "-Wl,-rpath,/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/lib" "-lunwind" "-ldl" "-Wl,--export-dynamic" "-o" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/libunwind_01.pass.cpp.dir/t.tmp.exe"
$ ":" "EXECUTED AS"
$ "/usr/bin/python3.11" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libcxx/utils/run.py" "--execdir" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/libunwind_01.pass.cpp.dir" "--" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/libunwind_01.pass.cpp.dir/t.tmp.exe"
# command stderr:
starting test1
t.tmp.exe: /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/src/AddressSpace.hpp:612: bool libunwind::LocalAddressSpace::findUnwindSections(pint_t, UnwindInfoSections &): Assertion `findResult.dlfo_eh_dbase == findResult.dlfo_map_start && "libunwind expects the base address for DW_EH_PE_datarel to be identical" "with the start address of the PT_GNU_EH_FRAME segment"' failed.

error: command failed with exit status: 250

--

********************
FAIL: llvm-libunwind-shared.cfg.in :: forceunwind.pass.cpp (10 of 12)
******************** TEST 'llvm-libunwind-shared.cfg.in :: forceunwind.pass.cpp' FAILED ********************
Script:
--
: 'COMPILED WITH';  /usr/lib/ccache/bin/i686-pc-linux-gnu-clang++ /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/test/forceunwind.pass.cpp  --target=i686-pc-linux-gnu -nostdinc++ -I /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/include -funwind-tables -std=c++2b -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings  -L /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/lib -Wl,-rpath,/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/lib -lunwind -ldl -Wl,--export-dynamic -o /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/forceunwind.pass.cpp.dir/t.tmp.exe
: 'EXECUTED AS';  /usr/bin/python3.11 /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libcxx/utils/run.py --execdir /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/forceunwind.pass.cpp.dir --  /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/forceunwind.pass.cpp.dir/t.tmp.exe
--
Exit Code: 250

Command Output (stdout):
--
$ ":" "COMPILED WITH"
$ "/usr/lib/ccache/bin/i686-pc-linux-gnu-clang++" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/test/forceunwind.pass.cpp" "--target=i686-pc-linux-gnu" "-nostdinc++" "-I" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/include" "-funwind-tables" "-std=c++2b" "-Werror" "-Wall" "-Wextra" "-Wshadow" "-Wundef" "-Wno-unused-command-line-argument" "-Wno-attributes" "-Wno-pessimizing-move" "-Wno-c++11-extensions" "-Wno-noexcept-type" "-Wno-atomic-alignment" "-Wno-user-defined-literals" "-Wno-tautological-compare" "-Wsign-compare" "-Wunused-variable" "-Wunused-parameter" "-Wunreachable-code" "-Wno-unused-local-typedef" "-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER" "-D_LIBCPP_DISABLE_AVAILABILITY" "-fcoroutines-ts" "-Werror=thread-safety" "-Wuser-defined-warnings" "-L" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/lib" "-Wl,-rpath,/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/lib" "-lunwind" "-ldl" "-Wl,--export-dynamic" "-o" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/forceunwind.pass.cpp.dir/t.tmp.exe"
$ ":" "EXECUTED AS"
$ "/usr/bin/python3.11" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libcxx/utils/run.py" "--execdir" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/forceunwind.pass.cpp.dir" "--" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/forceunwind.pass.cpp.dir/t.tmp.exe"
# command stderr:
t.tmp.exe: /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/src/AddressSpace.hpp:612: bool libunwind::LocalAddressSpace::findUnwindSections(pint_t, UnwindInfoSections &): Assertion `findResult.dlfo_eh_dbase == findResult.dlfo_map_start && "libunwind expects the base address for DW_EH_PE_datarel to be identical" "with the start address of the PT_GNU_EH_FRAME segment"' failed.

error: command failed with exit status: 250

--

********************
FAIL: llvm-libunwind-shared.cfg.in :: signal_frame.pass.cpp (11 of 12)
******************** TEST 'llvm-libunwind-shared.cfg.in :: signal_frame.pass.cpp' FAILED ********************
Script:
--
: 'COMPILED WITH';  /usr/lib/ccache/bin/i686-pc-linux-gnu-clang++ /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/test/signal_frame.pass.cpp  --target=i686-pc-linux-gnu -nostdinc++ -I /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/include -funwind-tables -std=c++2b -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings  -L /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/lib -Wl,-rpath,/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/lib -lunwind -ldl -Wl,--export-dynamic -o /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/signal_frame.pass.cpp.dir/t.tmp.exe
: 'EXECUTED AS';  /usr/bin/python3.11 /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libcxx/utils/run.py --execdir /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/signal_frame.pass.cpp.dir --  /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/signal_frame.pass.cpp.dir/t.tmp.exe
--
Exit Code: 250

Command Output (stdout):
--
$ ":" "COMPILED WITH"
$ "/usr/lib/ccache/bin/i686-pc-linux-gnu-clang++" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/test/signal_frame.pass.cpp" "--target=i686-pc-linux-gnu" "-nostdinc++" "-I" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/include" "-funwind-tables" "-std=c++2b" "-Werror" "-Wall" "-Wextra" "-Wshadow" "-Wundef" "-Wno-unused-command-line-argument" "-Wno-attributes" "-Wno-pessimizing-move" "-Wno-c++11-extensions" "-Wno-noexcept-type" "-Wno-atomic-alignment" "-Wno-user-defined-literals" "-Wno-tautological-compare" "-Wsign-compare" "-Wunused-variable" "-Wunused-parameter" "-Wunreachable-code" "-Wno-unused-local-typedef" "-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER" "-D_LIBCPP_DISABLE_AVAILABILITY" "-fcoroutines-ts" "-Werror=thread-safety" "-Wuser-defined-warnings" "-L" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/lib" "-Wl,-rpath,/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/lib" "-lunwind" "-ldl" "-Wl,--export-dynamic" "-o" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/signal_frame.pass.cpp.dir/t.tmp.exe"
$ ":" "EXECUTED AS"
$ "/usr/bin/python3.11" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libcxx/utils/run.py" "--execdir" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/signal_frame.pass.cpp.dir" "--" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/signal_frame.pass.cpp.dir/t.tmp.exe"
# command stderr:
t.tmp.exe: /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/src/AddressSpace.hpp:612: bool libunwind::LocalAddressSpace::findUnwindSections(pint_t, UnwindInfoSections &): Assertion `findResult.dlfo_eh_dbase == findResult.dlfo_map_start && "libunwind expects the base address for DW_EH_PE_datarel to be identical" "with the start address of the PT_GNU_EH_FRAME segment"' failed.

error: command failed with exit status: 250

--

********************
FAIL: llvm-libunwind-shared.cfg.in :: libunwind_02.pass.cpp (12 of 12)
******************** TEST 'llvm-libunwind-shared.cfg.in :: libunwind_02.pass.cpp' FAILED ********************
Script:
--
: 'COMPILED WITH';  /usr/lib/ccache/bin/i686-pc-linux-gnu-clang++ /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/test/libunwind_02.pass.cpp  --target=i686-pc-linux-gnu -nostdinc++ -I /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/include -funwind-tables -std=c++2b -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings  -L /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/lib -Wl,-rpath,/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/lib -lunwind -ldl -Wl,--export-dynamic -o /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/libunwind_02.pass.cpp.dir/t.tmp.exe
: 'EXECUTED AS';  /usr/bin/python3.11 /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libcxx/utils/run.py --execdir /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/libunwind_02.pass.cpp.dir --  /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/libunwind_02.pass.cpp.dir/t.tmp.exe
--
Exit Code: 250

Command Output (stdout):
--
$ ":" "COMPILED WITH"
$ "/usr/lib/ccache/bin/i686-pc-linux-gnu-clang++" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/test/libunwind_02.pass.cpp" "--target=i686-pc-linux-gnu" "-nostdinc++" "-I" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/include" "-funwind-tables" "-std=c++2b" "-Werror" "-Wall" "-Wextra" "-Wshadow" "-Wundef" "-Wno-unused-command-line-argument" "-Wno-attributes" "-Wno-pessimizing-move" "-Wno-c++11-extensions" "-Wno-noexcept-type" "-Wno-atomic-alignment" "-Wno-user-defined-literals" "-Wno-tautological-compare" "-Wsign-compare" "-Wunused-variable" "-Wunused-parameter" "-Wunreachable-code" "-Wno-unused-local-typedef" "-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER" "-D_LIBCPP_DISABLE_AVAILABILITY" "-fcoroutines-ts" "-Werror=thread-safety" "-Wuser-defined-warnings" "-L" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/lib" "-Wl,-rpath,/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/lib" "-lunwind" "-ldl" "-Wl,--export-dynamic" "-o" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/libunwind_02.pass.cpp.dir/t.tmp.exe"
$ ":" "EXECUTED AS"
$ "/usr/bin/python3.11" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libcxx/utils/run.py" "--execdir" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/libunwind_02.pass.cpp.dir" "--" "/tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/runtimes_build-abi_x86_32.x86/Output/libunwind_02.pass.cpp.dir/t.tmp.exe"
# command stderr:
t.tmp.exe: /tmp/portage/sys-libs/llvm-libunwind-16.0.0.9999/work/libunwind/src/AddressSpace.hpp:612: bool libunwind::LocalAddressSpace::findUnwindSections(pint_t, UnwindInfoSections &): Assertion `findResult.dlfo_eh_dbase == findResult.dlfo_map_start && "libunwind expects the base address for DW_EH_PE_datarel to be identical" "with the start address of the PT_GNU_EH_FRAME segment"' failed.

error: command failed with exit status: 250

--

********************
********************
Failed Tests (4):
  llvm-libunwind-shared.cfg.in :: forceunwind.pass.cpp
  llvm-libunwind-shared.cfg.in :: libunwind_01.pass.cpp
  llvm-libunwind-shared.cfg.in :: libunwind_02.pass.cpp
  llvm-libunwind-shared.cfg.in :: signal_frame.pass.cpp


Testing Time: 0.82s
  Unsupported: 5
  Passed     : 3
  Failed     : 4

Thanks for checking this, @mgorny!
Well, I guess I will have to dig deeper, then...
Can you share a (preferably minimal) command line how to reproduce the test failures on a 64-bit Linux machine?

Thanks for checking this, @mgorny!
Well, I guess I will have to dig deeper, then...
Can you share a (preferably minimal) command line how to reproduce the test failures on a 64-bit Linux machine?

Please try configuring as:

CC=i686-pc-linux-gnu-clang CXX=i686-pc-linux-gnu-clang++ cmake ../runtimes -G Ninja -DLLVM_ENABLE_RUNTIMES=libunwind -DCMAKE_CXX_COMPILER_TARGET=i686-pc-linux-gnu

i686-pc-linux-gnu-clang and i686-pc-linux-gnu-clang++ are just symlinks to the clang executable.

remove assert completely

avogelsgesang edited the summary of this revision. (Show Details)Sep 15 2022, 5:26 AM

Thanks for those build instructions! I was able to reproduce the test failures.
The updated review now fixes the failures for me. Could you please double-check if it also fixes the failures for you?

I also updated the description with the reasoning on why I think this is the correct, minimal fix

mgorny accepted this revision.Sep 15 2022, 5:48 AM

Thanks. I can confirm that i686 works and passes all tests with this patch.

avogelsgesang added subscribers: MaskRay, compnerd.

@MaskRay and @compnerd could I get a review from you on this change, please :)

Not sure if this is the correct approach. As an alternative solution, I could also imagine to pass through the dlfo_eh_dbase to the LocalAddressSpace::getEncodedP function.

Afaict, libunwind currently only correctly supports dlfo_eh_dbase == dlfo_map_start becase:

  • Looking at LocalAddressSpace::getEncodedP, we see that DW_EH_PE_datarel is only supported if datarelBase is set.
  • The only places which passes a non-zero datarelBase are EHHeaderParser<A>::{decodeEHHdr,findFDE}. Both those invocations pass ehHdrStart as datarelBase.
  • The invocations of EHHeaderParser<A>::{decodeEHHdr,findFDE} pass info.dwarf_index_section as ehHdrStart.
  • info.dwarf_index_section is identical to dlfo_map_start.

At least on Linux 32-bit x86, I dlfo_eh_dbase is not equal to dlfo_map_start, though. I guess the current change works because DW_EH_PE_datarel is not actually used...

I won't insist but I'd personally prefer if you could commit this as-is for now, if it doesn't introduce any regressions compared to status quo. I'd like to start packaging Clang 16.x snapshots on Gentoo as part of an effort to give it better test coverage, and this is a blocker for me right now.

My understanding is, that I am not supposed to merge to main until after I got approval from the libunwind review group.
Not sure how the priority of following those process requirements compare to the unblocking Gentoo testing. I am too new to LLVM to really make a call here...

@MaskRay @compnerd @ldionne are you fine with me merging this even without a review first? Of course, I am happy to address any follow-up comments which might come up during a post-commit review

This commit now removes this compile time assertion and simply.

Simply what?

MaskRay accepted this revision.EditedSep 15 2022, 6:42 PM

In glibc, DLFO_STRUCT_HAS_EH_DBASE is only defined to 1 on i386 and nios2. We don't support nios2.

glibc/elf/dl-find_object.h says that when DLFO_STRUCT_HAS_EH_DBASE is 1, eh_dbase is the relocated DT_PLTGOT value.
So in a previous revision assert(findResult.dlfo_eh_dbase == findResult.dlfo_map_start && ...) was wrong.

This revision is now accepted and ready to land.Sep 15 2022, 6:42 PM
avogelsgesang edited the summary of this revision. (Show Details)Sep 16 2022, 6:29 AM

Thanks for the quick review, @MaskRay!

From https://www.gnu.org/software/libc/manual/html_node/Dynamic-Linker-Introspection.html, I thought that eh_dbase "is the base address for DW_EH_PE_datarel DWARF encodings".
Not sure how this relates to the "relocated DT_PLTGOT value".

To unblock @mgorny, I shipped this commit now. I updated the commit message to document that I am not 100% sure what the meaning of dlfo_eh_dbase is supposed to be. Hopefully, this will be helpful if anyone has to touch this code again in the future