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

Don't use mmap on macOS #302

Merged
merged 11 commits into from
Mar 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jobs:
- run: cargo test --no-default-features --features "dbghelp std"
- run: cargo test --no-default-features --features "dbghelp std verify-winapi"
- run: cargo test --manifest-path crates/cpp_smoke_test/Cargo.toml
- run: cargo test --manifest-path crates/macos_frames_test/Cargo.toml
- run: cargo test --features libbacktrace --manifest-path crates/without_debuginfo/Cargo.toml
- run: cargo test --features "libbacktrace coresymbolication" --manifest-path crates/without_debuginfo/Cargo.toml
- run: cargo test --features "libbacktrace gimli-symbolize" --manifest-path crates/without_debuginfo/Cargo.toml
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ edition = "2018"

[workspace]
members = ['crates/cpp_smoke_test']
exclude = ['crates/without_debuginfo']
exclude = ['crates/without_debuginfo', 'crates/macos_frames_test']

[dependencies]
cfg-if = "0.1.10"
Expand Down
4 changes: 3 additions & 1 deletion crates/backtrace-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ fn main() {

// `mmap` does not exist on Windows, so we use
// the less efficient `read`-based code.
if target.contains("windows") {
// Using `mmap` on macOS causes weird isseus - see
// https://github.com/rust-lang/rust/pull/45866
if target.contains("windows") || target.contains("darwin") {
build.file("src/libbacktrace/read.c");
} else {
build.file("src/libbacktrace/mmapio.c");
Expand Down
8 changes: 8 additions & 0 deletions crates/macos_frames_test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "macos_frames_test"
version = "0.1.0"
authors = ["Aaron Hill <[email protected]>"]
edition = "2018"

[dependencies.backtrace]
path = "../.."
1 change: 1 addition & 0 deletions crates/macos_frames_test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// intentionally blank
30 changes: 30 additions & 0 deletions crates/macos_frames_test/tests/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Based on from https://github.com/rust-lang/rust/blob/2cb0b8582ebbf9784db9cec06fff517badbf4553/src/test/ui/issues/issue-45731.rs
// This needs to go in a crate by itself, since it modifies the dSYM for the entire test
// output directory.
//
// Note that this crate is *not* part of the overall `backtrace-rs` workspace,
// so that it gets its own 'target' directory. We manually invoke this test
// in .github/workflows/main.yml by passing `--manifest-path` to Cargo
#[test]
#[cfg(target_os = "macos")]
fn backtrace_no_dsym() {
use std::{env, fs, panic};

// Find our dSYM and replace the DWARF binary with an empty file
let mut dsym_path = env::current_exe().unwrap();
let executable_name = dsym_path.file_name().unwrap().to_str().unwrap().to_string();
assert!(dsym_path.pop()); // Pop executable
dsym_path.push(format!(
"{}.dSYM/Contents/Resources/DWARF/{0}",
executable_name
));
let _ = fs::OpenOptions::new()
.read(false)
.write(true)
.truncate(true)
.create(false)
.open(&dsym_path)
.unwrap();

backtrace::Backtrace::new();
}