Skip to content

Some test failures in 0.7.0 when compiled gcc -O2 #440

@musicinmybrain

Description

@musicinmybrain

I was working on updating the Fedora package to 0.7.0 and encountered a couple of test failures:

97% tests passed, 2 tests failed out of 65
Total Test time (real) =   0.76 sec
The following tests FAILED:
	 41 - ryml-test-scalar_literal (Failed)
	 42 - ryml-test-scalar_folded (Subprocess aborted)

I was able to reproduce these in a git checkout on Fedora 40 (x86_64) by setting the same build flags and options as the RPM build; here I encountered a third test with failures,

99% tests passed, 3 tests failed out of 1644

Total Test time (real) =  21.90 sec

The following tests FAILED:
         41 - ryml-test-scalar_literal (Failed)
         42 - ryml-test-scalar_folded (Subprocess aborted)
        1543 - ryml-test-suite-W4TN-in_yaml-events (Failed)

To reproduce in a checkout, I imitated the RPM build. This uses the default options from the %cmake RPM macro, plus:

  • -GNinja – because it is faster and has no real disadvantages
  • -DRYML_CXX_STANDARD=14 – for compatibility with the current packaged gtest, which no longer supports C++11; changing this to C++17 makes no difference
  • -DRYML_BUILD_TESTS:BOOL=ON
  • -DRYML_TEST_FUZZ:BOOL=OFF – so that we do not have to include the contents of https://github.com/biojppm/rapidyaml-data in the source RPM

That looks like:

gh repo clone biojppm/rapidyaml
cd rapidyaml
git checkout v0.7.0
git submodule update --init --recursive

CFLAGS="${CFLAGS:--O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer }" ; export CFLAGS ;
CXXFLAGS="${CXXFLAGS:--O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer }" ; export CXXFLAGS ;
FFLAGS="${FFLAGS:--O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I/usr/lib64/gfortran/modules }" ; export FFLAGS ; 
FCFLAGS="${FCFLAGS:--O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I/usr/lib64/gfortran/modules }" ; export FCFLAGS ; 
VALAFLAGS="${VALAFLAGS:--g}" ; export VALAFLAGS ;
RUSTFLAGS="${RUSTFLAGS:--Copt-level=3 -Cdebuginfo=2 -Ccodegen-units=1 -Cstrip=none -Cforce-frame-pointers=yes --cap-lints=warn}" ; export RUSTFLAGS ; 
LDFLAGS="${LDFLAGS:--Wl,-z,relro -Wl,--as-needed  -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1  }" ; export LDFLAGS ;
LT_SYS_LIBRARY_PATH="${LT_SYS_LIBRARY_PATH:-/usr/lib64:}" ; export LT_SYS_LIBRARY_PATH ;
CC="${CC:-gcc}" ; export CC ;
CXX="${CXX:-g++}" ; export CXX

/usr/bin/cmake \
        -S "." \
        -B "redhat-linux-build" \
        -DCMAKE_C_FLAGS_RELEASE:STRING="-DNDEBUG" \
        -DCMAKE_CXX_FLAGS_RELEASE:STRING="-DNDEBUG" \
        -DCMAKE_Fortran_FLAGS_RELEASE:STRING="-DNDEBUG" \
        -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \
        -DCMAKE_INSTALL_DO_STRIP:BOOL=OFF \
        -DCMAKE_INSTALL_PREFIX:PATH=/usr \
        -DINCLUDE_INSTALL_DIR:PATH=/usr/include \
        -DLIB_INSTALL_DIR:PATH=/usr/lib64 \
        -DSYSCONF_INSTALL_DIR:PATH=/etc \
        -DSHARE_INSTALL_PREFIX:PATH=/usr/share \
        -DLIB_SUFFIX=64 \
        -DBUILD_SHARED_LIBS:BOOL=ON \
        -GNinja \
        -DRYML_CXX_STANDARD=14 \
        -DRYML_BUILD_TESTS:BOOL=ON \
        -DRYML_TEST_FUZZ:BOOL=OFF

/usr/bin/cmake --build "redhat-linux-build" -j16 --verbose
/usr/bin/cmake --build "redhat-linux-build" -j16 --verbose --target ryml-test-run-verbose

By trial and error, I was able to minimize that to the following:

gh repo clone biojppm/rapidyaml
cd rapidyaml
git checkout v0.7.0
git submodule update --init --recursive

CXXFLAGS='-O2' /usr/bin/cmake -S . -B build \
        -DCMAKE_CXX_FLAGS_RELEASE:STRING="-DNDEBUG" \
        -DRYML_BUILD_TESTS:BOOL=ON

/usr/bin/cmake --build build -j16 --verbose
/usr/bin/cmake --build build -j16 --verbose --target ryml-test-run-verbose

In short, in order to reproduce this, it seems to suffice to set -O2 -NDEBUG.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions