Hi everyone,

i have a strange behaviour of the JIT in DotNet 8.0.

I have created a small demo project (on GitHub)

The crashing code is not verry complex. It is contained in a Cpp-Library compiled to DotNet-IL (managed C++). It is just doing some basic double math with a pow().

I can work arraund this problem by slightly changing the code but that is not satisfying. I whant to understand what i am doing wrong in c++ or if there is a bug in the JIT compiler or C++ compiler.

The code is working in a debug build and even the first 1000+ calls in a release build are working fine. At the point the Jit compiles the method again in stage 2 with full optimization the code starts crashing.

The crashing code is wrapped in a Try-Catch in the CS-Console project.

When setting a break point in the release build (after the first exception) to inspect the situation everything runs perfectly. Even after removint the break point and continue the execution the code runs fine.

Would be really nice if some one can help me with this.

Thanks in advanced!

  • porgamrer
    link
    fedilink
    arrow-up
    2
    ·
    10 months ago

    I can’t help with the bug and I don’t know what your project’s constraints are, but it’s worth noting that this isn’t the recommended way to mix C# and native code anymore.

    I don’t think C++/CLI is deprecated, but you’ll find a lot more community resources if you’re using native C++ and binding it via the C ABI.