Skip to content

Commit

Permalink
Merge pull request #1065 from bugsnag/nickdowell/fix-thread-queue-nam…
Browse files Browse the repository at this point in the history
…e-crash

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
nickdowell committed Apr 9, 2021
2 parents 33db51d + a6d9253 commit f3f37db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMach.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,19 +307,20 @@ 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_ptr =
(dispatch_queue_t *)idInfo->dispatch_qaddr;
dispatch_queue_t dispatch_queue = NULL;
// 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 (dispatch_queue_ptr == NULL || idInfo->thread_handle == 0 ||
*dispatch_queue_ptr == NULL) {
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) {
BSG_KSLOG_TRACE(
"This thread doesn't have a dispatch queue attached : %p", thread);
return false;
}

dispatch_queue_t dispatch_queue = *dispatch_queue_ptr;
const char *queue_name = dispatch_queue_get_label(dispatch_queue);
if (queue_name == NULL) {
BSG_KSLOG_TRACE("Error while getting dispatch queue name : %p",
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Changelog

### Bug fixes

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

* Improve timestamp accuracy to fix breadcrumbs that are reported to occur after the error.
[#1062](https://github.com/bugsnag/bugsnag-cocoa/pull/1062)

Expand Down

0 comments on commit f3f37db

Please sign in to comment.