Skip to content

VCRuntime incompatibility with older version in mutex code #4730

Description

Describe the bug

VS 17.10 C++ runtime broke following code. Code is compiled with VS 17.10 but it doesnt work anymore with previously deployed VC runtime.

Command-line test case

C:\Temp>type ConsoleApplication5.cpp
#include <iostream>
#include <mutex>
std::mutex mtx;

void testmethod() {
        std::scoped_lock lock{ mtx };
        std::cout << "lock worked!\n";
}
int main()
{
    std::cout << "Start!\n";
    testmethod();
    std::cout << "End!\n";
}

Microsoft (R) C/C++ Optimizing Compiler Version 19.40.33811 for x64
  Copyright (C) Microsoft Corporation.  All rights reserved.
  cl /c /Zi /W3 /WX- /diagnostics:column /sdl /O2 /Oi /GL /D NDEBUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /Gy /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /std:c++17 /permissive- /Fo"x64\Release\\" /Fd"x64\Release\vc143.pdb" /external:W3 /Gd /TP /FC /errorReport:prompt ConsoleApplication5.cpp

C:\Temp>.\ConsoleApplication5.exe
Start!

C:\Temp>

Expected behavior

Lock does not crash.
Crashing computer had following version of VCRuntime
msvcp140.dll 14.32.31326.0
vcruntime140.dll 14.32.31326.0

working computer has
msvcp140.dll 14.40.33810.0
vcruntime140.dll 14.40.33810.0

C:\Temp>.\ConsoleApplication5.exe
Start!
lock worked!
End!

C:\Temp>

``

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis issue is incorrect or by design

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions