bus1 / dbus-broker

Linux D-Bus Message Broker
https://github.com/bus1/dbus-broker/wiki
Apache License 2.0
661 stars 78 forks source link

Test 48/49 libcstdaux-1failure with Clang #357

Closed ms178 closed 2 months ago

ms178 commented 2 months ago

Trying to build dbus-broker 36 with Clang 18.1.3 from https://mirrors.edge.kernel.org/pub/tools/llvm/ on CachyOS with super conservative cflags, I see the following test failure. I've seen this with Clang and some older dbus-broker revisions for a while now. Everything works fine when using GCC 13.2.1 instead. CPU is Intel Haswell-EP.

export CC=clang
export CXX=clang++
export CC_LD=lld
export CXX_LD=lld
export AR=llvm-ar
export NM=llvm-nm
export STRIP=llvm-strip
export OBJCOPY=llvm-objcopy
export OBJDUMP=llvm-objdump
export READELF=llvm-readelf
export RANLIB=llvm-ranlib
export HOSTCC=clang
export HOSTCXX=clang++
export HOSTAR=llvm-ar
export CPPFLAGS="-D_FORTIFY_SOURCE=0"
export CFLAGS="-O2 -march=native -mtune=native -fcf-protection=none -mharden-sls=none"
export CXXFLAGS="${CFLAGS} -Wp,-U_GLIBCXX_ASSERTIONS"
export LDFLAGS="-Wl,-O3,--as-needed -fuse-ld=lld"
export CCLDFLAGS="$LDFLAGS"
export CXXLDFLAGS="$LDFLAGS"
export ASFLAGS="-D__AVX__=1 -D__AVX2__=1 -D__FMA__=1"
48/49 libcstdaux-1 / Basic API Behavior                       FAIL            0.19s   killed by signal 6 SIGABRT
>>> ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 MALLOC_PERTURB_=247 /tmp/makepkg/dbus-broker-git/src/build/subprojects/libcstdaux-1/src/test-basic
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― ✀  ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
stderr:
test-basic: ../dbus-broker-git/subprojects/libcstdaux-1/src/test-basic.c:548: void test_basic_gnuc(int): Assertion `false && "!__builtin_constant_p(c_align_to(8, non_constant_expr ? 8 : 16))"' failed.
―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

49/49 dbus-broker:unit / D-Bus I/O Queues                     OK              0.11s

Summary of Failures:

48/49 libcstdaux-1 / Basic API Behavior               FAIL            0.19s   killed by signal 6 SIGABRT
dvdhrm commented 2 months ago

This was driving me insane. This is a test that simply verifies that an expression is not constant, so it does not really care for the values of the expression. But it turns out, newer LLVM sees the non_constant_expr value being used as divisor in a previous test, and thus rightfully deduces that it cannot be 0 and thus optimizes the expression into a constant.

Now fixed in: https://github.com/c-util/c-stdaux/commit/6bc45c0f6e14df97bb4869d8202cf5d020c97fa8

This has no impact on dbus-broker, but merely affects the test-suite.

Thanks a lot!