Skip to content

Conversation

@Will-MingLun-Li
Copy link
Contributor

@Will-MingLun-Li Will-MingLun-Li commented Mar 14, 2025

dump_crash_context only read values of CrashContext, so we can just pass in the reference and don't need to pass the value. This is useful when used with crash handler.

For example, currently the code below wouldn't work, and crash_context can't be converted to type CrashContext since it doesn't implement Copy trait

  CRASH_HANDLER
      .set(
          crash_handler::CrashHandler::attach(unsafe {
              crash_handler::make_crash_event(|crash_context| {  // <- This is of type &CrashContext
                  let mut minidump_file = std::fs::File::create("dump.mdmp").expect("failed to create file");

                  minidump_writer::minidump_writer::MinidumpWriter::dump_crash_context(
                      crash_context,
                      None,
                      &mut minidump_file,
                  );

                  crash_handler::CrashEventResult::Handled(false)
              })
          })
          .expect("CrashHandler should be initialized"),
      )
      .expect("CRASH_HANDLER should be set");

@Jake-Shadle Jake-Shadle merged commit ad8c49e into rust-minidump:main Mar 17, 2025
16 checks passed
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.

2 participants