-
Notifications
You must be signed in to change notification settings - Fork 796
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
Program runs fine in Debug but crashes in Release #12333
Comments
Thank you for this bug report. I've confirmed the behaviour is the same in all of
So at least it's not a regression. thanks |
So my understanding is that .NET floating point code can differ between Release and Debug - my understanding is that floating point values can stay in registers longer in Release mode and precisions can be different. (32 bit --> 80 bit internally in Intel preocessors). I assume that's what's doing on here. If we can narrow this down to a repro much smaller we may be able to clarify. |
I've confirmed this is a codegen bug, thank you |
Labelling as a regression - it's strictly speaking not but it's important to fix |
I've found minimal repro. [<Struct>]
type ColorF =
val r: float32
val g: float32
val b: float32
new (r, g, b) = {
ColorF.r = r
ColorF.g = g
ColorF.b = b
}
static member (+) (first: ColorF, second: ColorF) =
ColorF(first.r + second.r, first.g + second.g, first.b + second.b)
let Issue12333 () =
for x = 0 to 1 do
printfn "iter %d" x
let mutable color: ColorF = ColorF()
printfn "init color %g %g %g" color.r color.g color.b
for s = 0 to 1 do
let temp = ColorF(0.1f, 0.1f, 0.1f)
color <- color + temp
printfn "color %g %g %g" color.r color.g color.b
[<EntryPoint>]
let main (argv: string[]): int =
Issue12333()
0 Debug output:
Release output:
Environment:
|
Yes, it's a zero-initialization bug related to backward branching. We had one of these before. |
Fix is in #12337 |
Fix is in. |
This program runs fine in Debug mode, but crashes in Release mode with optimizations on. The relevant portion is the 3 nested for-loops that loop over the bitmap and samples. For each pixel, multiple rays are cast and then the result is averaged (anti-aliasing). As you can see, I add the colors up and then divide to get the average. Finally, in the ColorF structure, the components are converted from a [0f - 1f] range to a [0 - 255] range. The exception thrown in Release mode is because the green component is > 1.1f, expected result is <= 1.0f. The code looks fine to me, so I thought this could be a compiler bug, as the program runs fine with optimizations disabled.
Repro steps
Project zip file if needed: raytracer.zip
Expected behavior
Output a "output.jpeg" image in Release mode.
Actual behavior
Exception thrown in Release mode.
The text was updated successfully, but these errors were encountered: