ohgodhowdidthis / trance

procedural RIST
Do What The F*ck You Want To Public License
43 stars 22 forks source link

Bug report - Random crashes. #3

Closed VickyPetal closed 8 years ago

VickyPetal commented 8 years ago

Every time I try to run the latest trance version, or the last few versions, it runs fine for a while - sometimes it will continue running for upwards of ten minutes, sometimes it'll only last two - and then crash. Because I have MSVC installed, it prompts me with option to debug; when I do so, it tells me that it's run into

"Unhandled exception at 0x00007FF666ADEDDE in trance.exe: 0xC0000094: Integer division by zero."

I am running 64-bit Windows 10 SP1, with an AMD Radeon R7 M260 running the latest drivers. I have previously encountered this issue on Windows 8, with earlier drivers, and on trance v0.1.1; I had hoped the issue would go away upon upgrading to the latest version, but it has not done so.

ohgodhowdidthis commented 8 years ago

I have never seen this, so probably down to some difference in how things are set up. Can you upload the session file or tell me what sorts of numbers of themes/programs/etc you have going on?

Does the debug option give you a file or line number? If you have MSVC installed you could probably compile in debug mode and find the source of the problem for sure.

ohgodhowdidthis commented 8 years ago

Do any of your themes have zero fonts assigned to them? If so, does adding some fonts fix the problem? I think I have found an issue similar to what you describe that occurs if there are no fonts present in some themes (but no time to work out what the cause is yet)

ohgodhowdidthis commented 8 years ago

I suppose it's also possible you're running out of (main or video) memory - did you try reducing the image cache size in the system settings?

VickyPetal commented 8 years ago

Sorry for taking so long to get back to this - as a matter of fact, one of my themes DID have zero fonts assigned to it! I'm testing now to see if that solves it.

Image cache size is fairly small, only 64 - I don't think I should be running out of memory with that.

I'll be back with more information (inc. session file) as soon as I can.

ohgodhowdidthis commented 8 years ago

Don't worry about more information, if you had no fonts that was probably the problem. Released a fix. Re-open if you still have issues.

MrEldritch commented 7 years ago

Same person, sorry about name change. Just noticed this and tested it out. I'm still getting the random crashes, even with the latest version.

I think the problem might actually be something else - I have a crappy Intel integrated card and an AMD GPU. When I was running it on the AMD, my GPU was running 99 degrees C, and I think hit 100 a couple of times, which may have contributed to instability.

Just to check, I forced my computer to run everything on the Intel integrated graphics, and so far it hasn't crashed and my computer is running 65-68 degrees. It's currently running in the background, will report back if it crashes on the Intel card.

MrEldritch commented 7 years ago

Hm - just got another crash. So I guess it's not that.

I haven't had much luck compiling it on my own system, so I can't provide any really helpful debug information, but the error message is telling me there's an integer division by zero, and when I look at the dissasembled output it's literally crashing on a division instruction:

00007FF60DE0EE5E div rax,rcx

RCX 0000000000000000
RAX 000000000000013A

So something about my system is causing it to hit a divide-by-zero error in the compiled code.

MrEldritch commented 7 years ago

WOOHOO! I actually got it to compile and got the compiled version to crash! Useful debug information ahoy!

The problem is cropping up in theme.cpp, in

Image ThemeBank::get_animation(bool alternate, std::size_t frame)
{
  auto& a = animation(alternate ? 2 : 1);
  std::lock_guard<std::mutex> lock{a.mutex};
  if (a.frames.empty()) {
    return {};
  }
  auto len = a.frames.size();
  auto f = frame % (2 * len - 2);
  f = f < len ? f : 2 * len - 2 - f;
  do_video_upload(a.frames[f]);
  return a.frames[f];
}

Specifically, the line auto f = frame % (2 * len - 2);

The variable values are currently:


    f   14757395258967641292        unsigned __int64

    frame   200      unsigned __int64

    len 1   unsigned __int64

So it looks like that if len is ever 1, then 2*1 - 1 = 0, and taking something mod 0 is Bad. I suppose the next question is why a.frames.size is spitting out a 1.