How does one debug silent crashes?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
KayleMaster
Party member
Posts: 234
Joined: Mon Aug 29, 2016 8:51 am

How does one debug silent crashes?

Post by KayleMaster »

A.k.a. crashes to desktop without any errors.
Is it possible to run it through visual studio debugger or something?
Any other debuggers that might help with this?

It's really frustrating when it crashes after 10-20 min of playing, and you can't determine what exactly caused it.
I'm using ffi, so I think that may be the source, but it is possible to at least give me a clue that, yes, the crash happened there?
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: How does one debug silent crashes?

Post by pgimeno »

These are the worst. I don't think you can do much more than take a look at the disassembly around the generated code that causes the crash, to try to match it to the real code, but that's hard work. I know how to do that with gdb, though, not with VS.

FFI issues can be subtle. See https://github.com/gvx/bitser/issues/9# ... -436060611
KayleMaster
Party member
Posts: 234
Joined: Mon Aug 29, 2016 8:51 am

Re: How does one debug silent crashes?

Post by KayleMaster »

Hah, coincidentally I also had to solve a silent crash with bitser - the buffer size was too small and overflowed causing a segmentation fault. It was painful to debug.

But doesn't Lua run embedded on C/C++ (Love2d)? If so, is it possible to run love2d with the project in Visual Studio's C\C++ debugger?
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: How does one debug silent crashes?

Post by grump »

KayleMaster wrote: Mon Dec 02, 2019 3:54 pm Hah, coincidentally I also had to solve a silent crash with bitser - the buffer size was too small and overflowed causing a segmentation fault. It was painful to debug.
If you favor speed over serialized size, you could take a look at my moonblob library. It's cleaner, well tested code, easier to debug in case of errors and much faster than bitser and bitser - but creates less compact results in the general case. Simple LÖVE example.
But doesn't Lua run embedded on C/C++ (Love2d)? If so, is it possible to run love2d with the project in Visual Studio's C\C++ debugger?
You can run any executable in a debugger, but the stacktrace you're getting from a crash in LuaJIT is ususally not very helpful; at least it was never helpful to me. Been in that situation a couple times myself.
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: How does one debug silent crashes?

Post by pgimeno »

grump wrote: Mon Dec 02, 2019 10:59 pm You can run any executable in a debugger, but the stacktrace you're getting from a crash in LuaJIT is ususally not very helpful; at least it was never helpful to me. Been in that situation a couple times myself.
No, a stack trace won't help, unfortunately. Examining the disassembly is the best bet, and then there's the problem that you have no symbols whatsoever.

I remember a thread dedicated to one of those. Did you find the issue?
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: How does one debug silent crashes?

Post by grump »

pgimeno wrote: Tue Dec 03, 2019 11:50 am I remember a thread dedicated to one of those. Did you find the issue?
I can't remember details anymore, just that examining my own code thoroughly in these situations always led me to the cause - usually off-by-one errors when accessing ffi-allocated memory - faster than trying to make sense of the crash context and disassembly in a debugger, which can be a pretty frustrating experience, at least for me.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Majestic-12 [Bot] and 50 guests