Dungeon Crawl Stone Soup Tracker - DCSS
Viewing Issue Advanced Details
11861 Bug Report crash random 2019-02-07 17:13 2019-02-07 17:13
advil Both  
All  
normal Both  
new 0.24 old branch  
all open  
none    
none  
0011861: Lua error handling vs c++ stack
Currently, we use lua in C mode, by wrapping the header includes in an `extern` block. This causes lua to use setjmp/longjmp for error handling. This isn't a great idea for C++ code, and can lead to memory leaks or stack corruption. We should probably start using lua in c++ mode (which has worked in my tests, but would need a lot more testing). Nice summary of the state of affairs from a useful SO thread*: "setjmp()/longjmp() completely subvert stack unwinding and therefore exception handling as well as RAII (destructors in general)."

When bad longjmp calls happen, they result in pretty opaque crashlogs (usually with an empty or uninterpretable stack), and even when run in a debugger don't usually result in an interpretable stack trace, so based on some recent experience with these crashes (see https://github.com/crawl/crawl/commit/091e5a18feeb [^] ), I wouldn't be surprised if many of the more opaque crashlogs we encounter could be related.

[*] https://stackoverflow.com/questions/1376085/c-safe-to-use-longjmp-and-setjmp [^]
Issue History
2019-02-07 17:13 advil New Issue

There are no notes attached to this issue.