Description
Description
On a managed .NET 5 C# project, I get intermittent errors, sometimes an AccessViolationException, other times ExecutionEngineException, and even NullReferenceException (?) with no managed code in sight on the debugger.
The code does mathematical optimization and is fully deterministic, however the exceptions are not always consistent even though they are frequent.
On the following scenarios these exceptions have never appeared so far (I tried a few times):
- Debug mode.
- Release mode with Optimize=False,
- Release mode with Optimize=True and COMPlus_JITMinOpts=1.
Unfortunately, I don't know how to create a small program to reproduce the problem, but there seemed to be a particular point where the code breaks the most:
For context, _complement
is declared as:
private readonly ImmutableArray<ulong> _complement
An extra detail: in the constructor I initialize a regular ulong[]
and use Unsafe.As<ulong[], ImmutableArray<ulong>>
to set _complement
.
Here is a misterious NullReferenceException (on a value type?!)
JIT and compiler optimizations have a lot of impact on the performance in this project so I don't think disabling these optimizations is a long term solution.
Configuration
.NET 5.0.0-preview.6.20305.6
Also tried preview 4 before and was getting similar exceptions.
category:correctness
theme:testing
skill-level:expert
cost:large