-
Notifications
You must be signed in to change notification settings - Fork 37
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
Disable capturing backtraces with HILTI exceptions in non-debug builds. #1578
Conversation
736a4c2
to
1ef389c
Compare
They can be expensive to capture, and aren't used anywhere by default unless explicitly requested. We change it so that the exception class still remains ABI compatible between release and debug builds. It's the compilation settings of the code including `exception.h` that determines if a backtrace it captured. Closes #1565.
1ef389c
to
305588f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we shouldn't instead use a std::optional
to capture the backtraces. This increases space requirements slightly, but I would guess shouldn't be perform horribly. I'll push a fixup to this branch.
hilti/runtime/include/exception.h
Outdated
@@ -66,7 +92,7 @@ class Exception : public std::runtime_error { | |||
|
|||
std::string _description; | |||
std::string _location; | |||
Backtrace _backtrace; | |||
std::unique_ptr<Backtrace> _backtrace; // null if not available |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unless there is a clear performance win when going with allocating this on the heap I'd say go with std::optional
instead here. That would avoid having to explicitly deal with std::unique_ptr
not being copyable which IMO is not the semantics we want for an Exception
.
hilti/runtime/include/exception.h
Outdated
// Note: We don't copy the backtrace here, as it's not clear what | ||
// that would mean. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't an exception be copyable, including its full state? I cannot see where outside of implementation details we care about the backtrace being unique.
They can be expensive to capture, and aren't used anywhere by default
unless explicitly requested.
Closes #1565.