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

Add support for compiling with Visual Studio 2019 #119

Open
NN--- opened this issue Aug 7, 2019 · 20 comments
Open

Add support for compiling with Visual Studio 2019 #119

NN--- opened this issue Aug 7, 2019 · 20 comments

Comments

@NN---
Copy link

NN--- commented Aug 7, 2019

AppVeyor has VS 2019

@lewissbaker
Copy link
Owner

See #125 for changes needed to support vs2019 on appveyor.

I have not yet merged it because vs2019 was failing some optimised tests.
I haven't had a chance to investigate the cause of these crashes (not sure if it's exposing a bug in cppcoro or a bug in msvc).

@NN---
Copy link
Author

NN--- commented Nov 17, 2019

There are known bugs with coroutines in MSVC with optimizations enabled.
Unfortunately I couldn't reproduce them in a way that I can give a sample project to MS.
If you have a consistent reproduction, you should ask MS to check it, and then they will fix.

@NN---
Copy link
Author

NN--- commented Nov 17, 2019

@joemmett
Copy link

Hi - I'm a developer on the MSVC team and am working on finishing the coroutine support in VS 2019. We've recently harnessed cppcoro as part of our internal testing of the toolchain and are internally tracking bugs related to the optimized test failures, but are running all the others regularly. I also have a small number of patches to submit to address some issues due to STL header reorganization that I hope to get into a PR soon.

@lewissbaker
Copy link
Owner

@joemmett I've updated the PR to rebuild with the latest Visual Studio 2019 on AppVeyor (MSVC 14.24.28314).

Compilation seems to be failing with odd front-end error messages:
https://ci.appveyor.com/project/lewissbaker/cppcoro/builds/30413745/job/1wf0ccttb8tegami#L35

Is MSVC getting getting confused by the use of captures within an immediately invoked coroutine lambda?

@NN---
Copy link
Author

NN--- commented Jan 29, 2020

You can try /experimental:newLambdaProcessor

@joemmett
Copy link

@lewissbaker Sort of - that was a bug with resolving certain names within a lambda, it doesn't necessarily need to be immediately invoked. It's specific to using /std:c++latest, but can be worked around by either using the switch suggested by @NN--- or, even better, /permissive-. I do recommend using /permissive- when you can.

I tried reproducing this merge locally and adding /permissive-. I get a good build and all tests pass except two that I also saw last week:

  1. A runtime crash in one of the async_auto_reset_event_tests in optimized x64 builds. This looks to be intermittent and I'm not sure if it's a codegen bug or some timing/race issue, but I've opened a bug against the back-end group for investigation.
  2. x86 optimized builds are failing the 'cancel read' test because the operation_cancelled exception is not being caught by the catch handler. I've filed this with the back-end group.

@lewissbaker
Copy link
Owner

Thanks @joemmett. I've updated the build config to add /permissive- and the CI builds seem to be getting farther now.

I'm still seeing the x86 optimised tests crash (I assume this is the issue you describe).

It's possible that the async_auto_reset_event_tests could be crashing because of a race condition in the static_thread_pool implementation that I've occasionally seen (e.g. see #114). Or it could be unrelated...

@tnovotny
Copy link

tnovotny commented May 4, 2020

Any progress on this?

@NN--- NN--- closed this as completed May 5, 2020
@NN--- NN--- reopened this May 5, 2020
@NN---
Copy link
Author

NN--- commented May 5, 2020

VS 2019 16.5 fixed issues with generators and lambda.
We have encountered them in our project too, but now we don’t see any issue.
Please try the latest version.

@NN---
Copy link
Author

NN--- commented May 5, 2020

VS 2019 16.5 fixed issues with generators and lambda.
We have encountered them in our project too, but now we don’t see any issue.
Please try the latest version. #

@tnovotny
Copy link

tnovotny commented May 5, 2020

I tried building the vs2019 branch with 16.5.4 and it did not build. I mainly get these two errors.

D:\work\externals\cppcoro\lib\cancellation_state.cpp(82): error C2220: the following warning is treated as an error
D:\work\externals\cppcoro\lib\cancellation_state.cpp(82): warning C4996: 'std::atomic_init': warning STL4028: std::atomic_init() overloads are deprecated in C++20. The constructors of std::atomic provide equivalent functionality. You can define _SILENCE_CXX20_ATOMIC_INIT_DEPRECATION_WARNING or _SILENCE_ALL_CXX20_DEPRECATION_WARNINGS to acknowledge that you have received this warning.
D:\work\externals\cppcoro\test\doctest\doctest.h(3552): error C2039: 'uncaught_exception': is not a member of 'std'
C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.26.28801\include\map(25): note: see declaration of 'std'

Just noticed it seems to pick up the Preview, maybe that is part of the problem?

I also tried building master, but cake did not do anything there.

D:\work\externals\cppcoro>cake
python: can't open file '...\cppcoro\tools\cake\src\run.py': [Errno 2] No such file or directory

@NN---
Copy link
Author

NN--- commented May 5, 2020

D:\work\externals\cppcoro\lib\cancellation_state.cpp(82): warning C4996: 'std::atomic_init': warning STL4028: std::atomic_init() overloads are deprecated in C++20. The constructors of std::atomic provide equivalent functionality. You can define _SILENCE_CXX20_ATOMIC_INIT_DEPRECATION_WARNING or _SILENCE_ALL_CXX20_DEPRECATION_WARNINGS to acknowledge that you have received this warning.

This one is fixed in master #140

Try merging from master and then build again.

D:\work\externals\cppcoro\test\doctest\doctest.h(3552): error C2039: 'uncaught_exception': is not a member of 'std'

This is deprecated in C++17 and removed in C++29
https://en.cppreference.com/w/cpp/error/uncaught_exception

There is int uncaught_exceptions() noexcept; instead.

#143

@tnovotny
Copy link

tnovotny commented May 5, 2020

Ok, after merging in master it looks much better. I still get the

error C2039: 'uncaught_exception': is not a member of 'std'

which I can fix, and I also get

...\cppcoro\test\multi_producer_sequencer_tests.cpp(118) : warning C6262: Function uses '131780' bytes of stack:  exceeds /analyze:stacksize '16384'.  Consider moving some data to heap.
...\cppcoro\test\multi_producer_sequencer_tests.cpp(162) : warning C6262: Function uses '131772' bytes of stack:  exceeds /analyze:stacksize '16384'.  Consider moving some data to heap.

@tnovotny
Copy link

tnovotny commented May 5, 2020

After patching doctest, I at least have some libs I can link against, but one of the tests fails, which in my case is OK for the moment as I was aiming for x64.

...\cppcoro\test\cancellation_token_tests.cpp(261):
TEST SUITE: cancellation_token tests
TEST CASE:  cancellation registration single-threaded performance

...\cppcoro\test\cancellation_token_tests.cpp(334): MESSAGE: Individual took 3625us (36.25 ns/item)

..\cppcoro\test\cancellation_token_tests.cpp(334): MESSAGE: Batch10 took 45694us (45.694 ns/item)

...\cppcoro\test\cancellation_token_tests.cpp(334): MESSAGE: Batch50 took 247985us (49.597 ns/item)

 starting write
 starting read
test build/windows_x86_msvc15_optimised/test/run.exe failed with exit code -1073740791 (0x-3ffffbf7)
Linking build\windows_x64_msvc15_debug\test\run.exe
Testing build/windows_x64_msvc15_debug/test/run.exe
Linking build\windows_x64_msvc15_optimised\test\run.exe
Generating code
Finished generating code
Testing build/windows_x64_msvc15_optimised/test/run.exe

@NN---
Copy link
Author

NN--- commented May 5, 2020

Can you try with 16.6 preview ? It might be a MSVC coroutine bug.

@joemmett
Copy link

joemmett commented May 5, 2020

@tnovotny @NN--- There is a known bug we are tracking internally related to exceptions not being caught on x86 only. I can't say for sure this is the same test that is failing from the log above, though.

@NN---
Copy link
Author

NN--- commented May 5, 2020

@joemmett Can you share more information how it is reproduced ?
We are using corourines heavily and would like to know if there are issues.
Thanks.

@joemmett
Copy link

joemmett commented May 5, 2020

@NN--- If it's the same bug, it's an issue with the exception in the "cancel read" test in file_tests.cpp not being caught. It's specific to X86 and only in optimized builds. The catch handler for operation_cancelled is not catching the exception thrown from the coroutine and it escapes out from the test function.

@tnovotny
Copy link

tnovotny commented May 5, 2020

recompiling with 16.6 doesn't change anything.

cake
MSVC (x64): C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.26.28801
MSVC (x86): C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.26.28801
...
===============================================================================
D:\work\externals\cppcoro\test\cancellation_token_tests.cpp(261):
TEST SUITE: cancellation_token tests
TEST CASE:  cancellation registration single-threaded performance
...
 starting write
 starting read
test build/windows_x86_msvc15_optimised/test/run.exe failed with exit code -1073740791 (0x-3ffffbf7)
...

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

4 participants