Skip to content

Commit 5aa2490

Browse files
committed
find proper request struct
1 parent c7a16af commit 5aa2490

File tree

3 files changed

+8
-14
lines changed

3 files changed

+8
-14
lines changed

Crashlytics/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Unrelased
2-
- [fixed] Conformed to Mach IPC security restrictions. Note: This change would potentially change mach exception types we receive from kernel which might affect issue clustering result. (#15393)
1+
# Unreleased
2+
- [fixed] Conformed to Mach IPC security restrictions. (#15393)
33

44
# 12.4.0
55
- [fixed] Make set development platform APIs to chain on Crashlytics context init promise.

Crashlytics/Crashlytics/Handlers/FIRCLSMachException.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static kern_return_t FIRCLSMachExceptionDispatchMessage(FIRCLSMachExceptionReadC
215215
// inherited.
216216
mach_port_t actual_port;
217217
kern_return_t kr;
218-
task_id_token_t token = message->task_id.name;
218+
task_id_token_t token = message->task_id_token_t.name;
219219
kr = task_identity_token_get_task_port(token, TASK_FLAVOR_CONTROL, &actual_port);
220220

221221
if (kr || actual_port != mach_task_self()) {
@@ -539,10 +539,7 @@ static void FIRCLSCrashedThreadLookup(MachExceptionProtectedMessage* message, th
539539
thread_act_array_t threadList;
540540
mach_msg_type_number_t threadCount;
541541

542-
// last 64 bits include thread id info
543-
MachExceptionProtectedThreadInfo protected_thread_info = *(MachExceptionProtectedThreadInfo *) &message->thread_id;
544542
kern_return_t kr = task_threads(mach_task_self(), &threadList, &threadCount);
545-
546543
if (kr != KERN_SUCCESS) {
547544
FIRCLSSDKLogError("Failed to get threads: %d\n", kr);
548545
return;
@@ -559,7 +556,7 @@ static void FIRCLSCrashedThreadLookup(MachExceptionProtectedMessage* message, th
559556
if (kr == KERN_SUCCESS) {
560557
FIRCLSSDKLog("Thread %d: Thread port: %d, thread id: %llx\n", i, thread, identifierInfo.thread_id);
561558

562-
if (protected_thread_info.thread_id == identifierInfo.thread_id) {
559+
if (message->thread_id == identifierInfo.thread_id) {
563560
FIRCLSSDKLog("Find crashed thread: %d\n", thread);
564561
*crashedThread = thread;
565562
}

Crashlytics/Crashlytics/Handlers/FIRCLSMachException.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,22 @@
2727

2828
#pragma mark Structures
2929
#pragma pack(push, 4)
30+
// run `mig -DMACH_EXC_SERVER_TASKIDTOKEN_STATE=1 mach/mach_exc.defs`
31+
// check mach_exc.h
3032
typedef struct {
3133
mach_msg_header_t head;
3234
/* start of the kernel processed data */
3335
mach_msg_body_t msgh_body;
34-
mach_msg_port_descriptor_t task_id;
35-
mach_msg_port_descriptor_t thread_id;
36+
mach_msg_port_descriptor_t task_id_token_t;
3637
/* end of the kernel processed data */
3738
NDR_record_t NDR;
39+
uint64_t thread_id;
3840
exception_type_t exception;
3941
mach_msg_type_number_t codeCnt;
4042
mach_exception_data_type_t code[EXCEPTION_CODE_MAX];
4143
mach_msg_trailer_t trailer;
4244
} MachExceptionProtectedMessage;
4345

44-
typedef struct {
45-
uint64_t pad1;
46-
uint64_t thread_id;
47-
} MachExceptionProtectedThreadInfo;
48-
4946
typedef struct {
5047
mach_msg_header_t head;
5148
NDR_record_t NDR;

0 commit comments

Comments
 (0)