-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[C++/CLI] Direct access of unmanaged thread_local variable from managed code causes unexpected NullReferenceException #42187
Comments
@LEI-Hongfaan What versions of VC++ and .NET are you using? |
@dotnet/jit-contrib Anyone familiar with the intersection of VC++ /clr, thread local variables, and JIT? |
This is related to runtime/src/coreclr/src/inc/jithelpers.h Line 179 in 6072e4d
It looks like this helper was not brought back as part of the adding managed C++ support back. |
@jkotas, is this a .NET 5 issue? |
.NET 3.1 shipped with this bug. It is not a .NET 3.1 -> 5.0 regression. We should either fix in both 3.1 and 5.0 or neither. |
Marking as 6.0 for now. |
@BruceForstall still planning on fixing this in 6.0? |
Is there an update on this issue? I am in the process of testing the migration of one the products I develop and it uses TLS in a mixed-mode C++ project. The TLS code (__declspec(thread)) is in a statically linked C++ library (non-managed) but is accessed from managed C++/CLI (code is now CLI as it was old syntax but the migration was required to target .NET Core 3.1). The exact same code works perfectly fine with .NET Framework 4.7.2 (which we will also be targeting). If there is a work around on how to get this to work, I am open to any suggestions. |
Having the same problem here, a simple thread_local static int, is making the application crash |
Description
Consider the following code
Expected behavior
I'm not very sure it's the right place to report the bug. It's more likely a problem of VC++ Compiler.
category:correctness
theme:managed-c++
skill-level:beginner
cost:medium
impact:small
The text was updated successfully, but these errors were encountered: