Rollup merge of #44384 - alexcrichton:osx-segfault, r=estebank

std: Fix a segfault on OSX with backtraces

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

Closes #44379
This commit is contained in:
Guillaume Gomez 2017-09-10 14:03:25 +02:00 committed by GitHub
commit 0e2dac7eba

View File

@ -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()