Skip to content

Commit

Permalink
#2074: Add support for vtAbort to be called during init process
Browse files Browse the repository at this point in the history
  • Loading branch information
thearusable committed Jun 21, 2024
1 parent d797363 commit dd8ff75
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/vt/configs/error/stack_out.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ std::string prettyPrintStack(DumpStackType const& stack) {
auto magenta = ::vt::debug::magenta();
auto yellow = ::vt::debug::yellow();
auto vt_pre = ::vt::debug::vtPre();
auto node = ::vt::theContext()->getNode();
auto node = ::vt::theContext() ? ::vt::theContext()->getNode() : -1;
auto node_str = ::vt::debug::proc(node);
auto prefix = vt_pre + node_str + " ";
auto separator = fmt::format("{}{}{:-^120}{}\n", prefix, yellow, "", reset);
Expand Down
9 changes: 7 additions & 2 deletions src/vt/runtime/runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ void Runtime::reset() {
void Runtime::abort(std::string const abort_str, ErrorCodeType const code) {
output(abort_str, code, true, true, false);

if (theConfig()->vt_throw_on_abort) {
if (theContext && theConfig()->vt_throw_on_abort) {
throw std::runtime_error(abort_str);
} else {
aborted_ = true;
Expand Down Expand Up @@ -640,7 +640,12 @@ void Runtime::output(
fmt::print(stderr, "{}\n", prefix);
}

if (!theConfig()->vt_no_stack) {
if (theContext == nullptr) {
// Too early in init process to check dump settings - always dump stack.
auto stack = debug::stack::dumpStack();
auto stack_pretty = debug::stack::prettyPrintStack(stack);
fmt::print("{}", stack_pretty);
} else if (!theConfig()->vt_no_stack) {
bool const on_abort = !theConfig()->vt_no_abort_stack;
bool const on_warn = !theConfig()->vt_no_warn_stack;
bool const dump = (error && on_abort) || (!error && on_warn);
Expand Down

0 comments on commit dd8ff75

Please sign in to comment.