dilevin / computer-graphics-ray-tracing

Computer Graphics Assignment about Ray Tracing
1 stars 5 forks source link

Some subtle differences between release and debug modes #7

Closed Kubik42 closed 5 years ago

Kubik42 commented 5 years ago

I'm seeing some small differences between my release and debug images. For example, here is sphere-packing.json

debug: debug release: release

Notice how the reflections of the spheres are larger in the release version. What could be wrong here? I built the project like so:

cmake -DCMAKE_BUILD_TYPE=Release -DHW2LIB_DIR=../lib/release/linux/ ..
WChrisK commented 5 years ago

Whenever I see something different between the release and debug builds, I start looking for undefined behavior, since the compiler in release mode is a lot more aggressive with what it'll try to do. Of course there's a million things that could cause UB in C++ which is what makes the language such a pain to use at times.

There's a tool you can probably use called UBSan, it may flat out tell you where any undefined behavior is located. It's worth a shot, if it finds something you may get a quick resolution. I haven't used it personally but friends I know have, and at my old job there were coworkers who swear by it. You can find more information here. It's on my bucket list to set up for a personal project of mine, so maybe now would be a good time for me to learn it as well.

There might be other reasons, but this is the first thing I'd try when faced with a debug/release output mismatch.

Kubik42 commented 5 years ago

Fixed by initializing all vectors to (0,0,0)