-
Notifications
You must be signed in to change notification settings - Fork 5k
JIT: avoid fp divide by zero in profile synthesis #113396
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
Conversation
This can trip up users that have enabled floating point exceptions. While we don't generally support changing the exception modes we also can easily avoid dividing by zero here. Addresses dotnet#113369
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
@amanasifkhalid PTAL Should be no diff. |
weight_t const smallFractionOfChange = 1e-9 * change; | ||
weight_t relDivisor = oldWeight; | ||
if (relDivisor < smallFractionOfChange) | ||
{ | ||
relDivisor = smallFractionOfChange; | ||
} | ||
|
||
weight_t const blockRelResidual = change / relDivisor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wondering can't it just be something like weight_t const blockRelResidual = change / (oldWeight + 1e-10)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that would have worked too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out @hez2010 had a better fix. If change
is zero we will end up with 0.0 / 0.0
which causes an "invalid FP operation" exception.
/backport to release/9.0-staging |
Started backporting to release/9.0-staging: https://github.com/dotnet/runtime/actions/runs/13814988612 |
The previous fix dotnet#113396 could still leave us trying to evaluate 0.0/0.0, which causes an invalid FP operation exception. Make sure the divisor is non-zero.
The previous fix #113396 could still leave us trying to evaluate 0.0/0.0, which causes an invalid FP operation exception. Make sure the divisor is non-zero.
The previous fix #113396 could still leave us trying to evaluate 0.0/0.0, which causes an invalid FP operation exception. Make sure the divisor is non-zero.
This can trip up users that have enabled floating point exceptions.
While we don't generally support changing the exception modes we also can easily avoid dividing by zero here.
Addresses #113369