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

[BUG] new Microsoft Visual C++ 2015-2022 Redistributable requires #define _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR #151

Closed
MDMS24 opened this issue Jun 9, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@MDMS24
Copy link

MDMS24 commented Jun 9, 2024

Been using thread_pool.hpp version 2.0.0, building executables using MSVS 2022 with platform toolset v143.
With the following installed on Windows 11, both the old thread_pool.hpp version 2.0.0 and the new BS_thread_pool.hpp version 4.1.0 work as expected. (We updated to BS_thread_pool.hpp version 4.1.0 to get your support.)

  • Microsoft Visual C++ 2015-2022 Redistributable (x64) - 14.38.33135
  • Microsoft Visual C++ 2015-2022 Redistributable (x86) - 14.38.33135

But with the most recent MSVS 2022 update (from VS 2022 17.9 to VS 2022 17.10), the above redistributables are also updated as follows:

  • Microsoft Visual C++ 2015-2022 Redistributable (x64) - 14.40.33810
  • Microsoft Visual C++ 2015-2022 Redistributable (x86) - 14.40.33810

And with the above-listed 14.40.33810 redistributables, our software running thread_pool.hpp version 2.0.0 and the new BS_thread_pool.hpp version 4.1.0 crashes. Crash happens on all Windows 11 computers (various hardware, various software configurations) that we've tried.

The aforementioned crash happens on the line attempting to declare a pool of threads:
BS::thread_pool pool;
*** Executing the above line is causing the crash.

Digging into the "VS 2022 17.10" changelog on Github: https://github.com/microsoft/STL/wiki/Changelog#vs-2022-1710

  • under Fixed Bugs, the first items is "Fixed mutex's constructor to be constexpr. #3824 #4000 #4339"
  • as a temporary fix, this changelog also indicates to do: "You can define _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR as an escape hatch."

As indicated above, my workaround to use BS_thread_pool.hpp with the newest MSVS 2022 update is to put:
#define _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR
as the very first line in the file BS_thread_pool.hpp

Can you recommend and/or implement are more correct fix that allows mutex to be of type constexpr ?

Thanks in advance,

Manfred Sever.

@MDMS24 MDMS24 added the bug Something isn't working label Jun 9, 2024
@Nelson-numerical-software

My two cents:
If you have version 14.40.33810 installed on your PC, you won't encounter any issues.
It's good practice to always verify that the runtime used to build the application is available on the target PC. If it is not installed, the installer should ensure its installation.

@bshoshany if you add #define _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR please made it optionnal.

@MDMS24
Copy link
Author

MDMS24 commented Jun 9, 2024 via email

@Nelson-numerical-software
Copy link

Nelson-numerical-software commented Jun 9, 2024

The point isn't to debate this here, but if you don't check the runtime, how can you be sure that your software works with your build on all platforms ?

It's not the responsibility of the libraries to handle this issue, but rather your Visual Studio configuration.

#ifdef _MSC_VER < 1940
#define _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR
#endif
#include <BS_thread_pool.hpp>

You can also add this directive directly in your Visual Studio configuration.

Discussion of M$ available here:
https://developercommunity.visualstudio.com/t/Access-violation-with-std::mutex::lock-a/10664660#T-ND10678728

@bshoshany
Copy link
Owner

Hi @MDMS24 and thanks for the bug report! Sorry for the late reply, I'm having a very busy week.

On my PC I currently have Visual Studio 2022 v17.10.2 with Microsoft Visual C++ 2015-2022 Redistributable v14.40.33810. However, my test program (BS_thread_pool_test.cpp) finishes all the tests successfully without crashing when compiled with MSVC.

Are you able to provide a minimal working example that demonstrates the crash you are encountering, so I can reproduce it on my end?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants