Crate crash_context

source ·
Expand description

This crate exposes a platform specific CrashContext which contains the details for a crash (signal, exception, etc). This crate is fairly minimal since the intended use case is to more easily share these crash details between different crates without requiring lots of dependencies, and is currently only really made for the purposes of the crates in this repo, and minidump-writer.

Linux/Android

This crate also contains a portable implementation of getcontext, as not all libc implementations (notably musl) implement it as it has been deprecated from POSIX.

Macos

One major difference on Macos is that the details in the CrashContext cannot be transferred to another process via normal methods (eg. sockets) and must be sent via the criminally undocumented mach ports. This crate provides a Client and Server that can be used to send and receive a CrashContext across processes so that you don’t have to suffer like I did.

Modules

  • Contains types and helpers for dealing with EXC_GUARD exceptions.
  • Unfortunately, sending a CrashContext to another process on Macos needs to be done via mach ports, as, for example, mach_task_self is a special handle that needs to be translated into the “actual” task when used by another process, this might be possible completely in userspace, but examining the source code for this leads me to believe that there are enough footguns, particularly around security, that this might take a while, so for now, if you need to use a CrashContext across processes, you need to use the IPC mechanisms here to get meaningful/accurate data
  • Contains types and helpers for dealing with EXC_RESOURCE exceptions.

Structs