crashpad-rs
Rust bindings for Google Crashpad crash reporting system.
Project Structure
Directory | Package Name | Description |
---|---|---|
crashpad-sys/ |
crashpad-rs-sys |
Low-level FFI bindings to Crashpad C++ library |
crashpad/ |
crashpad-rs |
Safe Rust wrapper API |
xtask/ |
- | Development automation (not published) |
Note: The directories are published with different names to avoid conflicts on crates.io:
crashpad-sys/
→crashpad-rs-sys
crashpad/
→crashpad-rs
Features
- Cross-platform: macOS, Linux, Windows, iOS, Android
- Safe API: Rust-safe wrapper around Crashpad C++ library
- Flexible Configuration: Runtime handler configuration
- Zero-copy: Minimal overhead for crash reporting
- Production Ready: Battle-tested crash reporting solution
Installation
Add to your Cargo.toml
:
[]
= "0.1"
Quick Start
use ;
use HashMap;
Configuration
Basic Configuration (Local Only)
// Minimal config - crashes saved locally, no upload
let config = builder
.handler_path // Required on desktop platforms
.database_path // Where to store crash dumps
.build;
Production Configuration
// Full configuration with upload server
let config = builder
.handler_path
.database_path
.metrics_path // Optional: metrics storage
.url
.rate_limit // Limit upload frequency
.compress_uploads // Compress before uploading
.build;
Platform-Specific Configuration
Desktop (macOS/Linux/Windows)
// Handler path is required for desktop platforms
let config = builder
.handler_path // Must point to handler executable
.database_path
.build;
iOS/tvOS/watchOS
// iOS uses in-process handler - no handler_path needed
let config = builder
.database_path // Relative to app's Documents directory
.url
.build;
Android
// Android can use external handler (as .so file in APK)
let config = builder
.handler_path // Renamed for APK distribution
.database_path
.build;
Environment-Based Configuration
// Adjust configuration based on environment
let config = if cfg! else ;
Platform Support
Platform | Architecture | Status | Handler Type |
---|---|---|---|
macOS | x86_64, aarch64 | ✅ Stable | External executable |
Linux | x86_64, aarch64 | ✅ Stable | External executable |
Windows | x86_64 | ✅ Stable | External executable |
iOS | arm64, x86_64 sim | ✅ Stable | In-process |
Android | arm, arm64, x86, x86_64 | ✅ Stable | External/In-process |
Examples
Running the Test Example
-
Build the example and handler
# Build everything including the handler # The handler will be at: target/debug/crashpad_handler # The example will be at: target/debug/examples/crashpad_test_cli
-
Run with handler in same directory (easiest)
# Copy handler to current directory # Run the example (will look for handler in current directory as fallback)
-
Run with environment variable
# Set handler path explicitly # Run from anywhere
-
Run directly with cargo (if handler is in PATH or current directory)
# If you have crashpad_handler in current directory or PATH
Note: The example looks for the handler in this order:
- Path specified in config (if provided)
CRASHPAD_HANDLER
environment variable- Same directory as the executable (fallback)
- Current working directory (fallback)
Handler Deployment
The crashpad_handler
executable must be available at runtime. Common approaches:
-
Same directory as application (simplest)
my-app/ ├── my-app └── crashpad_handler
-
System path (for installed applications)
/usr/local/bin/crashpad_handler
-
Environment variable (flexible deployment)
-
Bundled in package (platform-specific)
- macOS: Inside .app bundle
- Linux: In AppImage or snap
- Android: As .so file in APK
- iOS: Not needed (in-process)
Documentation
For Library Users
- API Documentation - Full API reference
- Integration Guide - Production integration
- Platform Notes - Platform-specific considerations
For Contributors
- Development Guide - Build, test, and contribute
- Architecture - Technical design decisions
- Conventions - Coding standards
Troubleshooting
Handler Not Found
- Verify handler executable exists and has execute permissions
- Check
CRASHPAD_HANDLER
environment variable - Explicitly set path in config:
.handler_path("/path/to/crashpad_handler")
- Ensure handler architecture matches application
Crashes Not Being Captured
- Confirm handler process is running
- Check database path has write permissions
- Verify network connectivity for uploads
License
Licensed under MIT license (LICENSE).
Contributing
Contributions are welcome! See DEVELOPING.md for build and test instructions.
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Security: Report security vulnerabilities to security@example.com