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

Signals are still reported as error even if they are ignored #1472

Closed
alokedesai opened this issue Nov 22, 2021 · 8 comments
Closed

Signals are still reported as error even if they are ignored #1472

alokedesai opened this issue Nov 22, 2021 · 8 comments

Comments

@alokedesai
Copy link
Contributor

Environment

How do you use Sentry?
Sentry SaaS (sentry.io)

Which SDK and version?
sentry.cocoa 7.0.3

Steps to Reproduce

  1. Explicitly ignore SIGIPE: signal(SIGPIPE, SIG_IGN)
  2. Send SIGPIPE to the process (kill -SIGPIPE {pid})

Expected Result

No crash in sentry--the signal was explicitly ignored by Sentry.

Actual Result

A fatal crash in Sentry--I think this because Sentry sets a custom signal handler but doesn't check if the previous handler is SIG_IGN first:

if (sigaction(fatalSignals[i], &action, &g_previousSignalHandlers[i]) != 0) {

@philipphofmann
Copy link
Member

Thanks for reporting this issue, @alokedesai. Would you please elaborate on why you want to ignore SIGIPE explicitly?

@alokedesai
Copy link
Contributor Author

alokedesai commented Nov 23, 2021

I work at warp.dev--our app is written in Rust with a very thin layer of Objective C. Rust by default ignores Sigpipe (see rust-lang/rust#13158), so it's not even something we're configuring directly, it's more a function of our stack. Generally, my understanding is that you should be ignoring SIGPIPE unless you're writing a CLI app since you don't want a broken pipe to terminate your app (see here as an example).

In practice this means that sending a SIGPIPE to our application does nothing (since SIGPIPE is ignored) but does cause Sentry to report an "unhanded", fatal Sigpipe crash even though the app ignored the signal and continued to run just fine.

@philipphofmann
Copy link
Member

Thanks, @alokedesai, for the detailed explanation.

@Swatinem, you know more about signal handlers than me. Does this change make sense to you?

@Swatinem
Copy link
Member

I think thats a reasonable thing to do (check the previous signal handler, and essentially forward the ignore)

@philipphofmann
Copy link
Member

We will put this on our backlog @alokedesai. This seems like a quick win, but we can't give you an ETA at the moment. Of course, we are happy to accept PRs 😀.

@alokedesai
Copy link
Contributor Author

I'm happy to send a PR for this, @Swatinem though just to confirm we're on the same page--it's not that we need to forward the ignore, it's that we should check if the existing handler is SIG_IGN and, if so, not intercept the signal or try to send a crash.

@Swatinem
Copy link
Member

Ah okay, maybe there was a bit of confusion. Checking the current handler and skipping registering our own would be good as well.

@alokedesai
Copy link
Contributor Author

Just sent out a very simple diff for this #1489. Would love ideas/links on how to add tests for this since it requires a real executable for correct signal handling.

Repository owner moved this from Needs Discussion to Done in Mobile & Cross Platform SDK Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants