Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Crash report failure when using Options::set_before_send #8

Open
Jake-Shadle opened this issue Jul 14, 2020 · 3 comments
Open

Crash report failure when using Options::set_before_send #8

Jake-Shadle opened this issue Jul 14, 2020 · 3 comments
Labels
bug Something isn't working upstream This is an upstream issue that can't be fixed here

Comments

@Jake-Shadle
Copy link
Contributor

Describe the bug
If Options::set_before_send is used, and a native crash occurs, sentry fails to serialize the envelope contain the minidump to disk, which means subsequent runs can't send the crash and it goes unreported.

To Reproduce

  1. Setup Sentry, including set_before send
let mut opts = sentry_native::Options::new();
opts.set_debug(config.verbose);

opts.set_before_send(|val: sentry_native::Value| {
    if let Some(event) = val.as_map() {
        if let Some(id) = event.get("event_id") {
            println!("sending sentry event {}", id.as_str().unwrap());
        }
    }

    val
});

let shutdown = opts.init()?;
  1. Force a crash
let s: &u32 = unsafe { &*std::ptr::null() };

println!("we are crashing by accessing a null reference: {}", *s);
  1. With debug output enabled for the SDK, you should see a line saying [sentry] DEBUG failed to open file "/<uuid>.envelope" for writing

Expected behavior
The envelope should be serialized to disk, and subsequent runs should send those envelopes to the upstream sentry server for consumption and analysis.

Environment:

  • OS: Fedora 32
  • Default transport both exhibit the same behavior
  • Version 5f4bf1f
  • Rust 1.44.1

Additional context
So after some digging, it appears as if some memory might be getting stomped during the before_send callback, I don't think it's in the native code as there doesn't seem to be much going on there, but I could of course be wrong. But basically, the options run field has the run_path which is the directory where sentry stores serialized envelopes and temporary crash dumps, but if the before_send callback is set and called, run_path ends up being an empty string, so when sentry creates the path to store the serialized envelope in by joining the run_path with the uuid + .envelope extension, which should be an absolute path, it ends up being just /<uuid>.envelope which then fails to be created and sentry gives up serializing the envelope and the crash is lost forever.

I would look into this more but once I realized that before_send was causing this I just stopped using it (it was only for logging purposes) so I could move on, but thought I would at least make this report so that there's a record of it. 🙂

@Jake-Shadle Jake-Shadle added the bug Something isn't working label Jul 14, 2020
@daxpedda
Copy link
Owner

I would look into this more but once I realized that before_send was causing this I just stopped using it (it was only for logging purposes) so I could move on, but thought I would at least make this report so that there's a record of it. 🙂

Thank you so much!

Is this behaviour on Linux? Because when Linux is going to switch to Crashpad (which is going to be with the next release), set_before_send will never be called, because the program will crash anyway, so all problems will be dealt with Crashpad.

@Jake-Shadle
Copy link
Contributor Author

Yes, this was linux, definitely looking forward to the crashpad change so that we can have the same mechanism on all our primary platforms.

@daxpedda daxpedda added the wontfix This will not be worked on label Jul 14, 2020
@daxpedda
Copy link
Owner

daxpedda commented Jul 14, 2020

I really wanted to keep the scope of this project to support Crashpad only, too bad #9 happened, thank you anyway.
I will just copy paste this upstream.

@daxpedda daxpedda removed their assignment Jan 12, 2021
@daxpedda daxpedda added upstream This is an upstream issue that can't be fixed here and removed wontfix This will not be worked on labels Feb 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working upstream This is an upstream issue that can't be fixed here
Projects
None yet
Development

No branches or pull requests

2 participants