Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

recursive_generator_tests fails on some MSVC configurations #53

Open
andreasbuhr opened this issue Jun 17, 2022 · 2 comments
Open

recursive_generator_tests fails on some MSVC configurations #53

andreasbuhr opened this issue Jun 17, 2022 · 2 comments

Comments

@andreasbuhr
Copy link
Owner

The unit test recursive_generator_tests fails on some MSVC configurations. Specifically, it is the test "exceptions thrown from nested call can be caught by caller" seen here:

TEST_CASE("exceptions thrown from nested call can be caught by caller")

On MSVC 2022, it fails only in Release or RelWithDebInfo mode and only in C++20 mode.
On MSVC 2019, it fails only in Release or RelWithDebInfo mode and only in C++20 mode and only if I upgrade doctest to version 2.4.7.
See the following table for all tests which were done:

MSVC Version C++ version Buildtype doctest version test result
2019 17 Debug 2.4.0 ok
2019 17 Debug 2.4.7 ok
2019 17 RelWithDebInfo 2.4.0 ok
2019 17 RelWithDebInfo 2.4.7 ok
2019 20 Debug 2.4.0 ok
2019 20 Debug 2.4.7 ok
2019 20 RelWithDebInfo 2.4.0 ok
2019 20 RelWithDebInfo 2.4.7 Unhandled SEH exception
2022 17 Debug 2.4.0 ok
2022 17 Debug 2.4.7 ok
2022 17 RelWithDebInfo 2.4.0 ok
2022 17 RelWithDebInfo 2.4.7 ok
2022 20 Debug 2.4.0 ok
2022 20 Debug 2.4.7 ok
2022 20 RelWithDebInfo 2.4.0 SIGSEGV
2022 20 RelWithDebInfo 2.4.7 SIGSEGV

The callstack of the crash is

`cppcoro::recursive_generator<unsigned int>::promise_type::yield_value'::`2'::awaitable::await_resume() recursive_generator.hpp:97
`DOCTEST_ANON_FUNC_22'::`2'::<lambda_1>::operator()<`DOCTEST_ANON_FUNC_22'::`2'::<lambda_1>$_ResumeCoro$1 &>(...) recursive_generator_tests.cpp:279
[Inlined] std::coroutine_handle::resume() coroutine:141
[Inlined] cppcoro::recursive_generator::promise_type::resume() recursive_generator.hpp:170
[Inlined] cppcoro::recursive_generator::promise_type::pull() recursive_generator.hpp:162
[Inlined] cppcoro::recursive_generator::iterator::operator++() recursive_generator.hpp:260
DOCTEST_ANON_FUNC_22() recursive_generator_tests.cpp:306
doctest::Context::run() doctest.h:6656
main(int, char **) doctest.h:6741
[Inlined] invoke_main() 0x00007ff60a675880
__scrt_common_main_seh() 0x00007ff60a67585e
<unknown> 0x00007ffc1d467034
<unknown> 0x00007ffc1f3e2651

To reproduce with doctest 2.4.0, the following procedure worked for me
(sha 167571d is master branch at time of writing)

git clone https://github.com/andreasbuhr/cppcoro
cd cppcoro
git checkout 167571d68652d376b25378b3bb9c77f62c812136
mkdir build
cd build
cmake -GNinja -DBUILD_TESTING=ON -DCMAKE_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
cmake --build . --parallel
ctest -R recursive --output-on-failure

For testing with doctest 2.4.7, use sha 93f1417.

The output I get from that is (MSVC 2022, C++20, RelWithDebInfo, doctest 2.4.0):

windows@DESKTOP-N6Q8ACG MINGW64 ~/development/reproduce
$ git clone https://github.com/andreasbuhr/cppcoro
Cloning into 'cppcoro'...
remote: Enumerating objects: 3427, done.
remote: Counting objects: 100% (77/77), done.
remote: Compressing objects: 100% (43/43), done.
remote: Total 3427 (delta 27), reused 47 (delta 15), pack-reused 3350
Receiving objects: 100% (3427/3427), 1.30 MiB | 5.25 MiB/s, done.
Resolving deltas: 100% (2224/2224), done.

windows@DESKTOP-N6Q8ACG MINGW64 ~/development/reproduce
$ cd cppcoro

windows@DESKTOP-N6Q8ACG MINGW64 ~/development/reproduce/cppcoro (master)
$ git checkout 167571d68652d376b25378b3bb9c77f62c812136
Note: switching to '167571d68652d376b25378b3bb9c77f62c812136'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 167571d Add gcc 11 to CI

windows@DESKTOP-N6Q8ACG MINGW64 ~/development/reproduce/cppcoro ((167571d...))
$ mkdir build

windows@DESKTOP-N6Q8ACG MINGW64 ~/development/reproduce/cppcoro ((167571d...))
$ cd build

windows@DESKTOP-N6Q8ACG MINGW64 ~/development/reproduce/cppcoro/build ((167571d...))
$

C:\Users\windows\development\reproduce\cppcoro\build>cmake -GNinja -DBUILD_TESTING=ON -DCMAKE_CXX_STANDARD=20 -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
-- The CXX compiler identification is MSVC 19.32.31329.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test _CXX_COROUTINES_SUPPORTS_MS_FLAG
-- Performing Test _CXX_COROUTINES_SUPPORTS_MS_FLAG - Success
-- Performing Test _CXX_COROUTINES_SUPPORTS_MS_HEAPELIDE_FLAG
-- Performing Test _CXX_COROUTINES_SUPPORTS_MS_HEAPELIDE_FLAG - Success
-- Performing Test _CXX_COROUTINES_SUPPORTS_TS_FLAG
-- Performing Test _CXX_COROUTINES_SUPPORTS_TS_FLAG - Failed
-- Performing Test _CXX_COROUTINES_SUPPORTS_CORO_FLAG
-- Performing Test _CXX_COROUTINES_SUPPORTS_CORO_FLAG - Failed
-- Looking for C++ include coroutine
-- Looking for C++ include coroutine - found
-- Performing Test _CXX_COROUTINES_FINAL_HEADER_COMPILES
-- Performing Test _CXX_COROUTINES_FINAL_HEADER_COMPILES - Success
-- Performing Test CXX_COROUTINES_NO_AWAIT_NEEDED
-- Performing Test CXX_COROUTINES_NO_AWAIT_NEEDED - Success
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - not found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/windows/development/reproduce/cppcoro/build

C:\Users\windows\development\reproduce\cppcoro\build>cmake --build . --parallel
[97/97] Linking CXX executable test\socket_tests.exe

C:\Users\windows\development\reproduce\cppcoro\build>ctest -R recursive --output-on-failure
Test project C:/Users/windows/development/reproduce/cppcoro/build
      Start 12: recursive generator tests-default constructed recursive_generator is empty
 1/13 Test #12: recursive generator tests-default constructed recursive_generator is empty ....................   Passed    0.03 sec
      Start 13: recursive generator tests-non-recursive use of recursive_generator
 2/13 Test #13: recursive generator tests-non-recursive use of recursive_generator ............................   Passed    0.01 sec
      Start 14: recursive generator tests-throw before first yield
 3/13 Test #14: recursive generator tests-throw before first yield ............................................   Passed    0.01 sec
      Start 15: recursive generator tests-throw after first yield
 4/13 Test #15: recursive generator tests-throw after first yield .............................................   Passed    0.01 sec
      Start 16: recursive generator tests-generator doesn't start executing until begin is called
 5/13 Test #16: recursive generator tests-generator doesn't start executing until begin is called .............   Passed    0.01 sec
      Start 17: recursive generator tests-destroying generator before completion destructs objects on stack
 6/13 Test #17: recursive generator tests-destroying generator before completion destructs objects on stack ...   Passed    0.01 sec
      Start 18: recursive generator tests-simple recursive yield
 7/13 Test #18: recursive generator tests-simple recursive yield ..............................................   Passed    0.01 sec
      Start 19: recursive generator tests-nested yield that yields nothing
 8/13 Test #19: recursive generator tests-nested yield that yields nothing ....................................   Passed    0.01 sec
      Start 20: recursive generator tests-exception thrown from recursive call can be caught by caller
 9/13 Test #20: recursive generator tests-exception thrown from recursive call can be caught by caller ........   Passed    0.01 sec
      Start 21: recursive generator tests-exceptions thrown from nested call can be caught by caller
10/13 Test #21: recursive generator tests-exceptions thrown from nested call can be caught by caller ..........***Exception: SegFault  0.01 sec
[doctest] doctest version is "2.4.0"
[doctest] run with "--help" for options
===============================================================================
C:\Users\windows\development\reproduce\cppcoro\test\recursive_generator_tests.cpp(248):
TEST SUITE: recursive_generator
TEST CASE:  exceptions thrown from nested call can be caught by caller

C:\Users\windows\development\reproduce\cppcoro\test\recursive_generator_tests.cpp(248): FATAL ERROR: test case CRASHED: SIGSEGV - Segmentation violation signal

===============================================================================
[doctest] test cases:      1 |      0 passed |      1 failed |     12 skipped
[doctest] assertions:      3 |      3 passed |      0 failed |
[doctest] Status: FAILURE!

      Start 22: recursive generator tests-recursive iteration performance
11/13 Test #22: recursive generator tests-recursive iteration performance .....................................   Passed    0.02 sec
      Start 23: recursive generator tests-usage in standard algorithms
12/13 Test #23: recursive generator tests-usage in standard algorithms ........................................   Passed    0.01 sec
      Start 24: recursive generator tests-fmap operator
13/13 Test #24: recursive generator tests-fmap operator .......................................................   Passed    0.01 sec

92% tests passed, 1 tests failed out of 13

Total Test time (real) =   0.34 sec

The following tests FAILED:
         21 - recursive generator tests-exceptions thrown from nested call can be caught by caller (SEGFAULT)
Errors while running CTest

@andreasbuhr
Copy link
Owner Author

@andreasbuhr
Copy link
Owner Author

I silenced these errors in the master branch now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant