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

Disable capturing backtraces with HILTI exceptions in non-debug builds. #1578

Merged
merged 2 commits into from
Oct 23, 2023

Conversation

rsmmr
Copy link
Member

@rsmmr rsmmr commented Oct 19, 2023

They can be expensive to capture, and aren't used anywhere by default
unless explicitly requested.

Closes #1565.

@rsmmr rsmmr force-pushed the topic/robin/gh-1565 branch from 736a4c2 to 1ef389c Compare October 21, 2023 07:52
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.
@rsmmr rsmmr force-pushed the topic/robin/gh-1565 branch from 1ef389c to 305588f Compare October 21, 2023 14:35
@rsmmr rsmmr requested a review from bbannier October 22, 2023 07:37
bbannier
bbannier previously approved these changes Oct 23, 2023
Copy link
Member

@bbannier bbannier left a 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.

@@ -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
Copy link
Member

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.

Comment on lines 54 to 55
// Note: We don't copy the backtrace here, as it's not clear what
// that would mean.
Copy link
Member

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.

@bbannier bbannier requested a review from awelzel October 23, 2023 08:41
@bbannier bbannier self-assigned this Oct 23, 2023
@bbannier bbannier merged commit 60ce83e into main Oct 23, 2023
17 of 22 checks passed
@bbannier bbannier deleted the topic/robin/gh-1565 branch October 23, 2023 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

&try / backtrack() usage too expensive due to unconditional stack unwinding
3 participants