this post was submitted on 16 Jan 2024
8 points (100.0% liked)

.NET

1482 readers
13 users here now

Getting started

Useful resources

IDEs and code editors

Tools

Rules

Related communities

Wikipedia pages

founded 1 year ago
MODERATORS
 

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!

top 2 comments
sorted by: hot top controversial new old
[–] atheken 3 points 10 months ago

You should probably report this as an issue on the dotnet runtime GitHub repo: https://github.com/dotnet/runtime

I would also suggest you include information on the hardware you’re using for this (architecture, ram, cpu, etc).

[–] porgamrer 2 points 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.