-
Notifications
You must be signed in to change notification settings - Fork 13.4k
cargo test with RUST_BACKTRACE causes SIGBUS #45731
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I have also been able to reproduce this. The same code got a SIGBUS on Mac OS, but the backtrace was printed as expected on Linux. Perhaps related to #44251? |
Stack trace of the SIGBUS:
No repro when using a custom stage1 instead of nightly 😕 |
@JohnColanduoni Any idea? Repro steps:
I suspect it has something to do with threading. This bug is no-repro on |
Regression was introduced in this range -- 4279e2b...8493813 Between |
So this implies to me two things:
I'm going to send a PR to disable libbacktrace on OSX due to the latter point. |
@kennytm What makes you suspect threading? IIRC |
@JohnColanduoni because I can't repro it if I used That said, the following isn't causing SIGBUS either: fn main() {
std::thread::spawn(|| panic!()).join().unwrap();
} |
This is definitely related to loading
It causes the appropriate crash on both nightly and beta (as long as you |
The offending line is Line 225 in ddd123e
Which means |
Something really hinky is definitely going on here. The memory access failure isn't the usual
Sure enough, according to I have no idea why (a) the dSYM is empty (b) loading libtest has anything to do with it (it's probably something more general) but it appears this isn't actually a memory safety issue (since the access will always either succeed or cause SIGBUS). The most immediate solutions are to either:
In any case I don't think #45760 is necessary, since this is a clean crash. |
Nice! It does seem weird that the dSYM is empty. The SIGBUS doesn't happen upon mapping the file, but upon access, right? It seems that even if we add a length check in backtrace_get_view there's still an issue where something is performing an out of bounds read on the mapped region. |
@sfackler Yes. The read is "in bounds" in the sense that (a) it is the right address and (b) there is a virtual memory mapping at that location that will prevent something else from getting mapped there. There's no danger that e.g. a |
Ah, sure - I was thinking more of a "semantically" out of bounds read. The underlying file is N bytes, and libbacktrace is trying to ready byte N + 10 or whatever. It's either going to fault or you'll be reading bogus zeroed data. I agree that turning off the mmap implementation is a reasonable approach (maybe everywhere?). |
I've figured out (broadly) what produces the empty I opened up a separate issue for that problem here. |
This also affects Servo (in a Strangely, after seeing a failure if I downgrade the compiler to a normally not-affected version I’ll still see the same failure until I run |
@SimonSapin may be that was rust-lang/cargo#4699 |
Fixes #45731 libbacktrace uses mmap if available to map ranges of the files containing debug information. On macOS `mmap` will succeed even if the mapped range does not exist, and a SIGBUS (with an unusual EXC_BAD_ACCESS code 10) will occur when the program attempts to page in the memory. To combat this we force `libbacktrace` to be built with the simple `read` based fallback on Apple platforms.
Disable `mmap` in `libbacktrace` on Apple platforms Fixes #45731 libbacktrace uses mmap if available to map ranges of the files containing debug information. On macOS `mmap` will succeed even if the mapped range does not exist, and a SIGBUS (with an unusual EXC_BAD_ACCESS code 10) will occur when the program attempts to page in the memory. To combat this we force `libbacktrace` to be built with the simple `read` based fallback on Apple platforms.
Fixes rust-lang#45731 libbacktrace uses mmap if available to map ranges of the files containing debug information. On macOS `mmap` will succeed even if the mapped range does not exist, and a SIGBUS (with an unusual EXC_BAD_ACCESS code 10) will occur when the program attempts to page in the memory. To combat this we force `libbacktrace` to be built with the simple `read` based fallback on Apple platforms.
The test |
@orivej Hi could you file a new issue for this? The log doesn't indicate a SIGBUS happened. |
Uh oh!
There was an error while loading. Please reload this page.
On nightly channel, having
RUST_BACKTRACE=1
orRUST_BACKTRACE=full
when running cargo test throws this error on any panic:Repro
Setup
The text was updated successfully, but these errors were encountered: