Skip to content

Correctly bubble up errors from libbacktrace #44525

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

Merged
merged 1 commit into from
Sep 20, 2017
Merged
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
14 changes: 11 additions & 3 deletions src/libstd/sys_common/gnu/libbacktrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ where F: FnMut(&[u8], libc::c_int) -> io::Result<()>
let ret;
let fileline_count = {
let state = unsafe { init_state() };
if state.is_null() {
return Err(io::Error::new(
io::ErrorKind::Other,
"failed to allocate libbacktrace state")
)
}
let mut fileline_win: &mut [FileLine] = &mut fileline_buf;
let fileline_addr = &mut fileline_win as *mut &mut [FileLine];
ret = unsafe {
Expand Down Expand Up @@ -62,8 +68,11 @@ pub fn resolve_symname<F>(frame: Frame,
let symname = {
let state = unsafe { init_state() };
if state.is_null() {
None
} else {
return Err(io::Error::new(
io::ErrorKind::Other,
"failed to allocate libbacktrace state")
)
}
let mut data = ptr::null();
let data_addr = &mut data as *mut *const libc::c_char;
let ret = unsafe {
Expand All @@ -80,7 +89,6 @@ pub fn resolve_symname<F>(frame: Frame,
CStr::from_ptr(data).to_str().ok()
}
}
}
};
callback(symname)
}
Expand Down