-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Run on .NET 8 Arm64 seems to remove some parts of a conditional statement, probably only after Tier 1 JIT compilation #99954
Comments
cc @dotnet/jit-contrib |
@kunalspathak PTAL. |
@kunalspathak can you give an update on this? Or if you're tied up can we find somebody else to dig in? |
Sorry, I forgot about this. I was able to repro this and I can confirm that this doesn't repro on .NET 9 |
The problem is the reverse condition was wrongly calculated as seen in screenshot( left= net9/correct, right= net8/wrong) We fixed it in #92316 and might need to backport. |
btw, this is easily reproducible with [MethodImpl(MethodImplOptions.NoInlining)]
private void Select(Entity trackingObject)
{
if (ShouldSelectEntity(trackingObject))
{
SelectEntity(trackingObject);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool ShouldSelectEntity(Entity entity)
{
...
} |
I verified this fix locally and it doesn't throw Exception anymore. |
This should be part of the upcoming .NET 8.0.5 |
@Louis-Antoine-Blais-Morin .NET 8.0.5 is now available -- when you get a chance can you verify it fixes this issue for you? |
@AndyAyersMS |
@Louis-Antoine-Blais-Morin - did you get a chance to validate this? |
Good morning, Providing feedback on this got of my radar for a while. I had time to test the correction today:
So, as far as I can see, the bug is fixed. |
Description
We have a code running that runs correctly on Windows x64 and that was running correctly on Arm64 with .NET 7.
Starting from .NET 8, we observed that one
if
statement does not seem to behave as written in the code.Extract of the code is like this:
We observed that the exception in
SelectEntity
is thrown, even if it should never happens.The code above is not sufficient to reproduce the bug. For the bug to be present, the above code, it needs to be part of a larger program. The initial program has been stripped greatly and is published here:
https://github.com/Louis-Antoine-Blais-Morin/JitBugArm64
It is still relatively large, but it seems that removing parts of the program seems to make the bug disappear. Maybe more effort can lead to a smaller code.
Reproduction Steps
https://github.com/Louis-Antoine-Blais-Morin/JitBugArm64
Expected behavior
The
if
statement should behave as expected in the C# code.Therefore, no exception should be thrown in the code linked to this bug.
Actual behavior
The
if
statement in theShouldSelectEntity
does not behave correctly.The function seems to returns
true
even ifentity.Score > m_scoreThreshold
.This seems to happen after a few seconds of correct operation.
I suspect that the behavior starts to be incorrect after Tier 1 JIT compilation.
Regression?
This is a regression since the program is working correctly with .NET 7.
The program is also working correctly under Windows x64.
Known Workarounds
The following workarounds seem to fix the behavior:
if ( ... || ...) return false;
by two individualif
statements.ShouldSelectEntity
method:[MethodImpl(MethodImplOptions.NoInlining)]
<DebugSymbols>true</DebugSymbols>
in the .csprojConfiguration
Processor Architecture is Arm64 Cortex A53 / Armv8-A.
Linux is "Yocto Kirkstone".
Other information
No response
The text was updated successfully, but these errors were encountered: