File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed
Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -111,10 +111,6 @@ std::filesystem::path get_crashlog_path() {
111111
112112void dfhack_save_crashlog () {
113113 char ** backtrace_strings = backtrace_symbols (crash_info.backtrace , crash_info.backtrace_entries );
114- if (!backtrace_strings) {
115- // Allocation failed, give up
116- return ;
117- }
118114 try {
119115 std::filesystem::path crashlog_path = get_crashlog_path ();
120116 std::ofstream crashlog (crashlog_path);
@@ -128,9 +124,14 @@ void dfhack_save_crashlog() {
128124 crashlog << " Signal " << signal << " \n " ;
129125 }
130126
131- // Skip the first backtrace entry as it will always be dfhack_crashlog_handle_(signal|terminate)
132- for (int i = 1 ; i < crash_info.backtrace_entries ; i++) {
133- crashlog << i - 1 << " > " << backtrace_strings[i] << " \n " ;
127+ if (crash_info.backtrace_entries >= 2 && backtrace_strings != nullptr ) {
128+ // Skip the first backtrace entry as it will always be dfhack_crashlog_handle_(signal|terminate)
129+ for (int i = 1 ; i < crash_info.backtrace_entries ; i++) {
130+ crashlog << i - 1 << " > " << backtrace_strings[i] << " \n " ;
131+ }
132+ } else {
133+ // Make it clear if no relevant backtrace was able to be obtained
134+ crashlog << " Failed to obtain relevant backtrace\n " ;
134135 }
135136 } catch (...) {}
136137
You can’t perform that action at this time.
0 commit comments