Naios / continuable

C++14 asynchronous allocation aware futures (supporting then, exception handling, coroutines and connections)
https://naios.github.io/continuable/
MIT License
815 stars 44 forks source link

unit-test/test-continuable-single fails on gcc 8.2 #13

Closed furkanusta closed 4 years ago

furkanusta commented 5 years ago

@Naios

unit-test/test-continuable-single results in segmentation fault on gcc 8.2 Also tested with clang++ 7.0 and it passes, and it looks like gcc6 on Travis also passes thus I am not sure if it is a compiler regression or something like an undefined behavior (I will update the post after testing with gcc-trunk)

Output of running the tests (successfull tests are ommitted):

../test/unit-test/single/test-continuable-flat-variant.cpp:70: Failure Expected equality of these values: e.cast() Which is: 4790218 CANARY Which is: 373671 ../test/unit-test/single/test-continuable-flat-variant.cpp:78: Failure Value of: e.is() Actual: false Expected: true [ FAILED ] flat_variant_single_test.is_copy_constructible (0 ms)

../test/unit-test/single/test-continuable-flat-variant.cpp:121: Failure Value of: variant.template is() Actual: false Expected: true ../test/unit-test/single/test-continuable-flat-variant.cpp:121: Failure Value of: variant.template is() Actual: false Expected: true ../test/unit-test/single/test-continuable-flat-variant.cpp:121: Failure Value of: variant.template is() Actual: false Expected: true ../test/unit-test/single/test-continuable-flat-variant.cpp:121: Failure Value of: variant.template is() Actual: false Expected: true ../test/unit-test/single/test-continuable-flat-variant.cpp:121: Failure Value of: variant.template is() Actual: false Expected: true ../test/unit-test/single/test-continuable-flat-variant.cpp:160: Failure Value of: destroyed Actual: false Expected: true [ FAILED ] flat_variant_single_test.test_leak_regression (1 ms)

../test/unit-test/single/test-continuable-result.cpp:152: Failure Value of: bool(e) Actual: false Expected: true ../test/unit-test/single/test-continuable-result.cpp:153: Failure Expected equality of these values: *e Which is: 11712264 CANARY Which is: 373671 ../test/unit-test/single/test-continuable-result.cpp:154: Failure Value of: e.is_value() Actual: false Expected: true

I also got several warnings on uninitialized variables but I am not sure if they are intentional or bugs.

../include/continuable/detail/utility/flat-variant.hpp:369:23: warning: ‘((void)+16)’ may be used uninitialized in this function [-Wmaybe-uninitialized]

../include/continuable/detail/utility/traits.hpp:99:35: warning: ‘((void)+8)’ may be used uninitialized in this function [-Wmaybe-uninitialized]

There should be a few more like these I can add those as well


Commit Hash

e23e363

Expected Behavior

Tests should pass

Actual Behavior

Some of the tests fail and program finishes with segmentation fault

Steps to Reproduce

cmake -G Ninja -DCMAKE_BUILD_TYPE=Release .. ninja test

Your Environment

Naios commented 5 years ago

Seems like a compiler regression, I'll take a look into this.

furkanusta commented 5 years ago

By the way I've just tested with gcc 9.0.1 (20190123) and I got

../test/unit-test/single/test-continuable-flat-variant.cpp:70: Failure Expected equality of these values: e.cast() Which is: 12740264 CANARY Which is: 373671 ../test/unit-test/single/test-continuable-flat-variant.cpp:78: Failure Value of: e.is() Actual: false Expected: true [ FAILED ] flat_variant_single_test.is_copy_constructible (0 ms)

../test/unit-test/single/test-continuable-flat-variant.cpp:121: Failure Value of: variant.template is() Actual: false Expected: true ../test/unit-test/single/test-continuable-flat-variant.cpp:121: Failure Value of: variant.template is() Actual: false Expected: true Segmentation fault (core dumped)

Also gcc 8.2 passes the tests on Debug mode if that helps

Naios commented 5 years ago

I could also reproduce this on GCC 8.2 in release mode as you described on Ubuntu 18.04. The flat-variant uses some optimization based on NDEBUG but disabling those doesn't solve the issue. I'll take a look into this.

Naios commented 5 years ago

It seems that this is a compiler bug indeed which could be related to https://gcc.gnu.org/bugzilla//show_bug.cgi?id=60165 :

/O3 triggers the warnings:

/usr/bin/c++ -DGTEST_HAS_PTHREAD=0 -DGTEST_LANG_CXX11=1 -I/home/src/test/unit-test/single -/home/src/test/unit-test -I/home/src/dep/googletest/googletest/googletest/include -I/home/src/include -system /home/src/dep/function2/function2/include -ftemplate-backtrace-limit=0 -O3 -DNDEBUG   -thread -Wall -pedantic -Wextra -std=gnu++14 -MD -MT test/unit-test/CMakeFiles/test-continuable-single.dir/single/test-continuable-flat-variant.cpp.o -MF test/unit-test/CMakeFiles/test-continuable-single.dir/single/test-continuable-flat-variant.cpp.o.d -o test/unit-test/CMakeFiles/test-continuable-single.dir/single/test-continuable-flat-variant.cpp.o -c /home/src/test/unit-test/single/test-continuable-flat-variant.cpp

whreas /O0 does not when the other flags stay equal:

/usr/bin/c++ -DGTEST_HAS_PTHREAD=0 -DGTEST_LANG_CXX11=1 -I/home/src/test/unit-test/single -/home/src/test/unit-test -I/home/src/dep/googletest/googletest/googletest/include -I/home/src/include -system /home/src/dep/function2/function2/include -ftemplate-backtrace-limit=0 -O0 -DNDEBUG   -thread -Wall -pedantic -Wextra -std=gnu++14 -MD -MT test/unit-test/CMakeFiles/test-continuable-single.dir/single/test-continuable-flat-variant.cpp.o -MF test/unit-test/CMakeFiles/test-continuable-single.dir/single/test-continuable-flat-variant.cpp.o.d -o test/unit-test/CMakeFiles/test-continuable-single.dir/single/test-continuable-flat-variant.cpp.o -c /home/src/test/unit-test/single/test-continuable-flat-variant.cpp
Warchant commented 5 years ago

With g++9.1.0 also fails.

$ g++-9 -v                                                                                                                         
Using built-in specs.
COLLECT_GCC=g++-9
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc/9.1.0/libexec/gcc/x86_64-apple-darwin18/9.1.0/lto-wrapper
Target: x86_64-apple-darwin18
Configured with: ../configure --build=x86_64-apple-darwin18 --prefix=/usr/local/Cellar/gcc/9.1.0 --libdir=/usr/local/Cellar/gcc/9.1.0/lib/gcc/9 --disable-nls --enable-checking=release --enable-languages=c,c++,objc,obj-c++,fortran --program-suffix=-9 --with-gmp=/usr/local/opt/gmp --with-mpfr=/usr/local/opt/mpfr --with-mpc=/usr/local/opt/libmpc --with-isl=/usr/local/opt/isl --with-system-zlib --with-pkgversion='Homebrew GCC 9.1.0' --with-bugurl=https://github.com/Homebrew/homebrew-core/issues --disable-multilib --with-native-system-header-dir=/usr/include --with-sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
Thread model: posix
gcc version 9.1.0 (Homebrew GCC 9.1.0)