Skip to content

Log backtrace on sigsegv and sigbus signals - #22

Merged
lionel- merged 5 commits into
mainfrom
feature/sigsegv-backtrace
Jun 12, 2023
Merged

Log backtrace on sigsegv and sigbus signals#22
lionel- merged 5 commits into
mainfrom
feature/sigsegv-backtrace

Conversation

@lionel-

Copy link
Copy Markdown
Contributor

Requires posit-dev/positron#708 otherwise the backtrace doesn't show up.

Screenshot 2023-06-08 at 18 14 29

@lionel-

Copy link
Copy Markdown
ContributorAuthor

I guess I should notify the next handler. Rust handles segfaults to detect and report stack overflows: rust-lang/rust#31333

@lionel-

Copy link
Copy Markdown
ContributorAuthor

I guess I should notify the next handler. Rust handles segfaults to detect and report stack overflows

To do this robustly we need a separate implementation for Windows and Unix so this doesn't seem worth it. I added a note about that.

I also added a note about R's segfault handler. It doesn't override our handler because we set R_SignalHandlers to 0 before startup.

@jmcphersjmcphers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

// Register segfault handler to get a backtrace. Should be after
// initialising `log!`. Note that R will not override this handler
// because we set `R_SignalHandlers` to 0 before startup.
stdext::traps::register_trap_handlers();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to disable this in release builds?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would there be a downside to leave it on? On the upside it could be useful for R developers to get a backtrace of their native code on crash.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right -- let's leave it on.

@lionel-
lionel-force-pushed the feature/sigsegv-backtrace branch from d2b3aab to 65b72a9CompareJune 12, 2023 09:07
@lionel-
lionel- merged commit fa816d2 into mainJun 12, 2023
@lionel-
lionel- deleted the feature/sigsegv-backtrace branch June 12, 2023 09:07
Sign up for freeto 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.

3 participants

@lionel-@jmcphers@kevinushey