Skip to content

Commit

Permalink
Exit using quick_exit(1) in error handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariusz Glebocki committed Nov 6, 2023
1 parent a3a9d1e commit 6b81b6c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/V3Error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ void V3ErrorGuarded::vlAbortOrExit() VL_REQUIRES(m_mutex) {
std::cerr << msgPrefix() << "Aborting since under --debug" << endl;
V3Error::vlAbort();
} else {
std::exit(1);
// Normal exit can't be invoked here because the program state is unknown. The stack won't
// unwind, no matter what exit function is used (except throwing an exception, whose can be
// disabled). Due to this destructors of local objects will never be executed. However,
// destructors of global objects (singletons) WILL be executed on std::exit(). This can
// lead to hangs, e.g. in V3ThreadPool. Letting the program deadlock in an error handler is
// quite a bad idea, so let's just exit without running any destructors.
std::quick_exit(1);
}
}

Expand Down

0 comments on commit 6b81b6c

Please sign in to comment.