0

My program crashes in Win/Maci release build, but works in Linux debug/release build and Maci/Win debug build. This is a large program, and I have not simplified it to a code that I can present here yet.

I have read related discussions here. For example,

What are some reasons a Release build would run differently than a Debug build

Program only crashes as release build -- how to debug?

Given that my code works in linux in both release/debug build, while fails only in Win/Maci release build, does this reduce the possibilities that I should look into?

Many thanks.

Community
  • 1
  • 1
Joe C
  • 2,757
  • 2
  • 26
  • 46
  • windows and (i think mac) zero out stack memory when it's allocated. I expect you've failed to initialise a variable. in windows it's zero. in linux it's random. – Richard Hodges Aug 08 '15 at 20:11
  • If it is random in linux, I should have sporadic crashes in linux, but this seems not my case. – Joe C Aug 08 '15 at 20:13
  • 1
    i think you're going to have to do what you probably have not done - write unit tests and run them in a release build – Richard Hodges Aug 08 '15 at 20:15
  • Does win/mac not zero out stack memory in its debug build? – Joe C Aug 08 '15 at 20:18
  • windows zeros out all newly allocated memory pages when they are created (e.g. your stack and heap). linux does not. I cannot speak for OSX with certainty but we have seen bugs manifest themselves in linux that did not appear in osx. whether your program is debug or release is irrelevant – Richard Hodges Aug 08 '15 at 20:27
  • If so, this does not match my case: win/maci release build crashes, which their debug builds work. – Joe C Aug 08 '15 at 20:51
  • 1
    you're overrunning a buffer somewhere, or inadvertently relying on a side effect that's optimised out of a release build. You need to write unit tests to prove that your interfaces are not lying. – Richard Hodges Aug 08 '15 at 21:55
  • OOB is exactly the problem. I have some code with important side effects in side a macro that will only run in debug build because that macro is defined to be nothing in release build. This eventually made out-of-bound access. – Joe C Aug 18 '15 at 12:18

0 Answers0