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

[PLAT-6948] Fix crash in bsg_ksmachgetThreadQueueName #1147

Merged
merged 1 commit into from
Jul 6, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,19 @@ bool bsg_ksmachgetThreadQueueName(const thread_t thread, char *const buffer,

thread_identifier_info_t idInfo = (thread_identifier_info_t)info;
dispatch_queue_t dispatch_queue = NULL;
uintptr_t junk = 0;
// thread_handle shouldn't be 0 also, because
// identifier_info->dispatch_qaddr = identifier_info->thread_handle +
// get_dispatchqueue_offset_from_proc(thread->task->bsd_info);
if (!idInfo->dispatch_qaddr || !idInfo->thread_handle ||
// sometimes the queue address is invalid, so avoid dereferencing
bsg_ksmachcopyMem((const void *)idInfo->dispatch_qaddr, &dispatch_queue,
sizeof(dispatch_queue)) != KERN_SUCCESS ||
!dispatch_queue) {
// Sometimes dispatch_queue is invalid which causes an EXC_BAD_ACCESS
// crash in dispatch_queue_get_label(). Check that dispatch_queue can
// be dereferenced to work around this.
bsg_ksmachcopyMem((const void *)dispatch_queue, &junk,
sizeof(junk)) != KERN_SUCCESS) {
BSG_KSLOG_TRACE(
"This thread doesn't have a dispatch queue attached : %p", thread);
return false;
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Changelog
[#1143](https://github.com/bugsnag/bugsnag-cocoa/pull/1143)
[#1138](https://github.com/bugsnag/bugsnag-cocoa/issues/1138)

* Fix a rare crash in `bsg_ksmachgetThreadQueueName`.
[#1147](https://github.com/bugsnag/bugsnag-cocoa/pull/1147)

## 6.10.0 (2021-06-30)

### Bug fixes
Expand Down