Skip to content

Commit

Permalink
Rollup merge of rust-lang#44384 - alexcrichton:osx-segfault, r=estebank
Browse files Browse the repository at this point in the history
std: Fix a segfault on OSX with backtraces

Apparently `dladdr` can succeed but still give you NULL pointers!

Closes rust-lang#44379
  • Loading branch information
GuillaumeGomez authored Sep 10, 2017
2 parents 1e4ab87 + f633284 commit 0e2dac7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/libstd/sys/unix/backtrace/printing/dladdr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ pub fn resolve_symname<F>(frame: Frame,
{
unsafe {
let mut info: Dl_info = intrinsics::init();
let symname = if dladdr(frame.exact_position, &mut info) == 0 {
let symname = if dladdr(frame.exact_position, &mut info) == 0 ||
info.dli_sname.is_null() {
None
} else {
CStr::from_ptr(info.dli_sname).to_str().ok()
Expand Down

0 comments on commit 0e2dac7

Please sign in to comment.