Bug#981610: libllvm11: segfault in writeConstants () llvm/ADT/DenseMap.h:613 on i386

Andreas Beckmann anbe at debian.org
Tue Feb 2 00:48:41 GMT 2021


Package: libllvm11
Version: 1:11.0.1-2
Severity: important

Hi,

when building pocl on i386 targeting the pentium4 cpu, two tests trigger
segmentation faults in libLLVM-11.so.1 (this is also reproducible when
building against llvm-9 and llvm-10).

This is the backtrace I get when running the failing test under gdb:

(gdb) run
Starting program: /srv/packaging/deb-src/OpenCL/pocl/pocl-upstream/build-local-i386/tests/kernel/kernel test_ldexp
Running test test_ldexp...
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0xf19a4af8 in writeConstants () at /build/llvm-toolchain-11-LNMihu/llvm-toolchain-11-11.0.1/llvm/include/llvm/ADT/DenseMap.h:613
613     /build/llvm-toolchain-11-LNMihu/llvm-toolchain-11-11.0.1/llvm/include/llvm/ADT/DenseMap.h: No such file or directory.
(gdb) bt
#0  0xf19a4af8 in writeConstants () at /build/llvm-toolchain-11-LNMihu/llvm-toolchain-11-11.0.1/llvm/include/llvm/ADT/DenseMap.h:613
#1  0xf1993499 in writeFunction () at /build/llvm-toolchain-11-LNMihu/llvm-toolchain-11-11.0.1/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:3219
#2  write () at /build/llvm-toolchain-11-LNMihu/llvm-toolchain-11-11.0.1/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:4317
#3  0xf198d608 in writeModule () at /build/llvm-toolchain-11-LNMihu/llvm-toolchain-11-11.0.1/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:4494
#4  0xf19979f8 in WriteBitcodeToFile () at /build/llvm-toolchain-11-LNMihu/llvm-toolchain-11-11.0.1/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:4520
#5  0xf7ca54ca in pocl_write_module () from /srv/packaging/deb-src/OpenCL/pocl/pocl-upstream/build-local-i386/lib/CL/libpocl.so.2.7.0
#6  0xf7cef16e in pocl_llvm_build_program () from /srv/packaging/deb-src/OpenCL/pocl/pocl-upstream/build-local-i386/lib/CL/libpocl.so.2.7.0
#7  0xf7c3c2ab in compile_and_link_program () from /srv/packaging/deb-src/OpenCL/pocl/pocl-upstream/build-local-i386/lib/CL/libpocl.so.2.7.0
#8  0xf7c39902 in POclBuildProgram () from /srv/packaging/deb-src/OpenCL/pocl/pocl-upstream/build-local-i386/lib/CL/libpocl.so.2.7.0
#9  0x56556602 in call_test (name=0xffffd563 "test_ldexp") at /srv/packaging/deb-src/OpenCL/pocl/pocl-upstream/tests/kernel/kernel.c:76
#10 0x56556861 in main (argc=2, argv=0xffffd3a4) at /srv/packaging/deb-src/OpenCL/pocl/pocl-upstream/tests/kernel/kernel.c:156

There is no easily minimizable testcase. Or do you have ideas how to
capture the state created by pocl when it is going to call into LLVM?

Instructions how to reproduce the segfault:
Rebuild the pocl package on i386 with DEB_BUILD_OPTIONS=pocl_cpu=pentium4
(pentium-m, pentium4m or anything newer would work as well, while
targeting any older cpu up to pentium3/pentium3m does not cause a segfault.
By default the package is built targeting i686 as supported baseline CPU.)
That will use llvm-9 currently, unless you adjust the version numbers in
the Build-Depends (and add libclang-cpp{10,11}-dev where needed).
This will cause 4 test failures, only the first two are relevant for this
bug report:

[...]
 28/147 Test  #19: kernel/test_ilogb ...................................................................***Failed  Error regular expression found in output. Regex=[FAIL]  1.19 sec
CMake Error at /build/pocl-1.6/cmake/run_test.cmake:34 (message):
  FAIL: Test exited with nonzero code (Segmentation fault):
[...]
 34/147 Test  #20: kernel/test_ldexp ...................................................................***Failed  Error regular expression found in output. Regex=[FAIL]  1.25 sec
CMake Error at /build/pocl-1.6/cmake/run_test.cmake:34 (message):
  FAIL: Test exited with nonzero code (Segmentation fault):
[...]
The following tests FAILED:
         19 - kernel/test_ilogb (Failed)
         20 - kernel/test_ldexp (Failed)
         34 - kernel/test_printf (Failed)
         87 - regression/struct_kernel_arguments (Failed)
[...]

>From within the build tree (pocl/obj-*) the failing tests can be run manually:

export OCL_ICD_VENDORS=$(pwd)/ocl-vendors/pocl-tests.icd
export POCL_BUILDING=1
export POCL_DEVICES=basic

gdb --args tests/kernel/kernel test_ilogb
gdb --args tests/kernel/kernel test_ldexp


Andreas



More information about the Pkg-llvm-team mailing list