0

I'm writing app that does some hot-reloading of files and from time to time, "First chance exception" is raised by debugger. I've tried several tests and I cannot figure out why this keep happening.

time_t time = fs::last_write_time("filename.xxx"); // fs = boost::filesystem

when I print time to console, all the time I get relatively normal values, like 1435695997, which make sense. When exception is raised, I have to dig into Locals and it has negative value instead, like -3689348814741910324. To me this look like non-initialized value of variable.

I've wrapped this into try and catch, but in my book, this is not really solution. Does anybody stumbled into anything like this?

sphere42
  • 156
  • 1
  • 11
  • The relevant code is missing. On a whim, I'll predict [Undefined Behaviour](https://en.wikipedia.org/wiki/Undefined_behavior). Anything can happen. Since you mention "hot reloading" are you by any chance mutating state shared by multiple threads without proper exclusive locking? – sehe Jun 30 '15 at 21:35
  • I have really not figure out reason why this keeps happening, although my solution was to check if value > 0. This is not optimal, but since I'm checking constantly for new changes in file it's working fine. – sphere42 Jan 05 '16 at 13:37
  • The relevant code is still missing. On what platforms does the issue arise? It might be a bug in Boost but we can't tell without information – sehe Jan 05 '16 at 13:40
  • -3689348814741910324 = 0xCCCCCCCCCCCCCCCC which means [you've accessed uninitialized memory](https://stackoverflow.com/q/370195/995714) – phuclv Aug 18 '18 at 11:05

0 Answers0