JIT: avoid fp divide by zero in profile synthesis#113396
JIT: avoid fp divide by zero in profile synthesis#113396AndyAyersMS merged 1 commit intodotnet:mainfrom
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
|
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.
Wondering can't it just be something like weight_t const blockRelResidual = change / (oldWeight + 1e-10)?
There was a problem hiding this comment.
Yeah, that would have worked too.
There was a problem hiding this comment.
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.
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. Co-authored-by: Andy Ayers <[email protected]>
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