Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print stack trace when flint aborts #3523

Merged
merged 1 commit into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions M2/Macaulay2/bin/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <string>
#include <thread>
#include <vector>
#include <flint/flint.h> // for flint_set_abort

/* ######################################################################### */

Expand Down Expand Up @@ -54,6 +55,7 @@ bool interrupts_interruptShield;
void* interpFunc(ArgCell* vargs);
void* profFunc(ArgCell* p);
void* testFunc(ArgCell* p);
void M2_flint_abort(void);

static void * GC_start_performance_measurement_0(void *) {
#ifdef GC_start_performance_measurement /* added in bdwgc 8 */
Expand Down Expand Up @@ -90,6 +92,8 @@ int main(/* const */ int argc, /* const */ char *argv[], /* const */ char *env[]

signal(SIGPIPE,SIG_IGN); /* ignore the broken pipe signal */

flint_set_abort(M2_flint_abort);

static struct ArgCell* M2_vargs;
M2_vargs = (ArgCell*) GC_MALLOC_UNCOLLECTABLE(sizeof(struct ArgCell));
M2_vargs->argv = argv; /* argument vector */
Expand Down Expand Up @@ -134,6 +138,11 @@ void stack_trace(std::ostream &stream, bool M2) {
}
}

void M2_flint_abort(void) {
stack_trace(std::cerr, false);
abort();
}

extern "C" {
void M2_stack_trace() { stack_trace(std::cout, false); }
#if PROFILING
Expand Down
Loading