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

New panic handler is not documented in the sentry crate #235

Closed
kornelski opened this issue Jul 7, 2020 · 2 comments
Closed

New panic handler is not documented in the sentry crate #235

kornelski opened this issue Jul 7, 2020 · 2 comments

Comments

@kornelski
Copy link
Contributor

It's hard to find documentation on replacement for register_panic_handler()

Documentation search: https://docs.rs/sentry/0.19.0/sentry/?search=panic finds https://docs.rs/sentry/0.19.0/sentry/integrations/panic/fn.panic_handler.html

but that function is just:

pub fn panic_handler(info: &PanicInfo)

but documentation doesn't have an example how this function is meant to be used. To me it looks like some internal callback, so I'm not sure if I'm supposed to install a panic hook myself.

The changelog says:

  • The integrations module was completely rewritten.

but there's no information how the new integrations look like.

@Swatinem
Copy link
Member

Swatinem commented Jul 7, 2020

The PanicIntegration is enabled by default:

/// When the `default_integrations` option is set to `true` (by default), the
/// following integrations will be added *before* any manually defined
/// integrations, depending on enabled feature flags:
///
/// 1. [`AttachStacktraceIntegration`] (`feature = "backtrace"`)
/// 2. [`DebugImagesIntegration`] (`feature = "debug-images"`)
/// 3. [`ErrorChainIntegration`] (`feature = "error-chain"`)
/// 4. [`ContextIntegration`] (`feature = "contexts"`)
/// 5. [`FailureIntegration`] (`feature = "failure"`)
/// 6. [`PanicIntegration`] (`feature = "panic"`)
/// 7. [`ProcessStacktraceIntegration`] (`feature = "backtrace"`)

And it will set itself as the panic handler automatically on setup, so no need to do that manually:

INIT.call_once(|| {
let next = panic::take_hook();
panic::set_hook(Box::new(move |info| {
panic_handler(info);
next(info);
}));
});

Does that sufficiently answer your question? Or what kind of documentation would make this clearer?

@kornelski
Copy link
Contributor Author

Yes, thank you. Automatic is much better than I expected — I thought I'd have to write a replacement for the function that has been removed.

intgr added a commit to intgr/rocket-sentry that referenced this issue Jul 22, 2020
* `register_panic_handler()` is no longer needed, the handler is
 installed automatically.
  See getsentry/sentry-rust#235
* Running `cargo update` may be necessary due to
  rwf2/Rocket#1377
intgr added a commit to intgr/rocket-sentry that referenced this issue Jul 22, 2020
* `register_panic_handler()` is no longer needed, the handler is
 installed automatically.
  See getsentry/sentry-rust#235
* Running `cargo update` may be necessary due to
  rwf2/Rocket#1377
bors bot added a commit to nervosnetwork/ckb that referenced this issue Sep 8, 2020
2266: fix: use forked metrics and forked sentry to fix RUSTSEC-2020-0041 temporarily r=yangby-cryptape a=yangby-cryptape

### Commits

- [chore(deps): bump crossbeam-channel from 0.4.3 to 0.4.4](728f5c3)
- [chore: remove direct dependencies of metrics exporters and observers](de3173a)
- [chore(deps): bump sentry from 0.16.0 to 0.19.1](e6b00c5)
  - [The module `sentry::internals` was deprecated.](https://github.com/getsentry/sentry-rust/blob/0.19.1/sentry/src/lib.rs#L133)
  - [`Sentry` will set itself as the panic handler automatically on setup, so no need to do that manually](../../../../getsentry/sentry-rust/issues/235#issuecomment-654832365)
- [chore: replace several dependencies sentry by sentry-core and sentry-log](80af819)
- [fix: use patched versions of metrics and sentry to fix RUSTSEC-2020-0041 temporarily](1eb9e0b)
  - [Changes of forked `metrics`](nervosnetwork/sentry-rust@1cdb9ff)
  - [Changes of forked `sentry`](nervosnetwork/metrics-rs@4fd13f6)

### References

- [RUSTSEC-2020-0041](../../../../rustsec/advisory-db/pull/381)

Co-authored-by: Boyu Yang <[email protected]>
bors bot added a commit to nervosnetwork/ckb that referenced this issue Sep 8, 2020
2266: fix: use forked metrics and forked sentry to fix RUSTSEC-2020-0041 temporarily r=yangby-cryptape a=yangby-cryptape

### Commits

- [chore(deps): bump crossbeam-channel from 0.4.3 to 0.4.4](728f5c3)
- [chore: remove direct dependencies of metrics exporters and observers](de3173a)
- [chore(deps): bump sentry from 0.16.0 to 0.19.1](e6b00c5)
  - [The module `sentry::internals` was deprecated.](https://github.com/getsentry/sentry-rust/blob/0.19.1/sentry/src/lib.rs#L133)
  - [`Sentry` will set itself as the panic handler automatically on setup, so no need to do that manually](../../../../getsentry/sentry-rust/issues/235#issuecomment-654832365)
- [chore: replace several dependencies sentry by sentry-core and sentry-log](80af819)
- [fix: use patched versions of metrics and sentry to fix RUSTSEC-2020-0041 temporarily](1eb9e0b)
  - [Changes of forked `metrics`](nervosnetwork/sentry-rust@1cdb9ff)
  - [Changes of forked `sentry`](nervosnetwork/metrics-rs@4fd13f6)

### References

- [RUSTSEC-2020-0041](../../../../rustsec/advisory-db/pull/381)

Co-authored-by: Boyu Yang <[email protected]>
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

No branches or pull requests

2 participants