From 2ebed5e396b655383be577ec55cfb756fcf328d4 Mon Sep 17 00:00:00 2001 From: Matthew Cline Date: Tue, 10 Nov 2009 02:01:09 -0800 Subject: Brief crash output for exit() crashes If a crash happens while exit() callbacks are being processed then just output a bare minimum of info to stderr, since anything we might want to reference would likely have been free'd, and we don't want to reference free'd memory (plus information about the player, level and monsters probably won't be of any help in tracking down a crash of that kind). --- crawl-ref/source/stuff.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'crawl-ref/source/stuff.cc') diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc index 9ca0204e12..d7f211bdea 100644 --- a/crawl-ref/source/stuff.cc +++ b/crawl-ref/source/stuff.cc @@ -356,6 +356,12 @@ void clear_globals_on_exit() clear_zap_info_on_exit(); } +// Used by do_crash_dump() to tell if the crash happened during exit() hooks. +// Not a part of crawl_state, since that's a global C++ instance which is +// free'd by exit() hooks when exit() is called, and we don't want to reference +// free'd memory. +bool CrawlIsExiting = false; + void end(int exit_code, bool print_error, const char *format, ...) { std::string error = print_error? strerror(errno) : ""; @@ -395,6 +401,7 @@ void end(int exit_code, bool print_error, const char *format, ...) } #endif + CrawlIsExiting = true; exit(exit_code); } -- cgit v1.2.3-54-g00ecf