FLEXTool / FLEX

An in-app debugging and exploration tool for iOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

System Logs menu is crashing on iOS 15

matrush opened this issue · comments

Environment

  • Platform+version: iOS 15
  • FLEX version: 4.5.0

Bug Report

We got some reports that the System Logs menu is crashing on iOS 15 consistently. I'm still looking into the cause and finding mitigations, but reporting here for awareness.

Thread #8 Crashed:
0 libsystem_platform.dylib 0x1f1296038 _platform_strcmp + 4152
1 App 0x109da9374 -[FLEXOSLogController handleStreamEntry:error:] (FLEXOSLogController.m:173)
2 LoggingSupport 0x198de9cd4 ___os_activity_stream_resume_with_filter_block_invoke + 244948
3 libxpc.dylib 0x1f12c84dc _xpc_connection_call_event_handler + 66780
4 libxpc.dylib 0x1f12c8900 _xpc_connection_mach_event + 67840
5 libdispatch.dylib 0x18038771c _dispatch_client_callout4 + 18204
6 libdispatch.dylib 0x1803a3794 _dispatch_mach_msg_invoke + 133012
7 libdispatch.dylib 0x18038ecb8 _dispatch_lane_serial_drain + 48312
8 libdispatch.dylib 0x1803a44e4 _dispatch_mach_invoke + 136420
9 libdispatch.dylib 0x18038ecb8 _dispatch_lane_serial_drain + 48312
10 libdispatch.dylib 0x18038f954 _dispatch_lane_invoke + 51540
11 libdispatch.dylib 0x18039a1a4 _dispatch_workloop_worker_thread + 94628
12 libsystem_pthread.dylib 0x1f129e0f0 _pthread_wqthread + 4336

I checked

strings Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/debugserver

Seems the type signature of os_log_message_s is the same:

{os_log_message_s=QQQ**{timeval=qi}{timezone=ii}I**Q*Q**ICB}

I don't have further context on what's going on here, but I feel it's probably safe to just wrap this weird logic to iOS 14 and below. Per limneos/oslog#1 it's unclear why we need it at all, so removing seems to be a good mitigation in this case.

I see your pr tries to avoid accessing entry->log_message.format at all, but what I think the issue actually is is that messageText is sometimes NULL. That is my first guess since the crash is inside strcmp and we're already checking entry->log_message.format for null. I have pushed a fix, please reopen this issue if the crash persists!

I see your pr tries to avoid accessing entry->log_message.format at all, but what I think the issue actually is is that messageText is sometimes NULL. That is my first guess since the crash is inside strcmp and we're already checking entry->log_message.format for null. I have pushed a fix, please reopen this issue if the crash persists!

This is not the case, the messageText is not nil, but the log_message.format is invalid (means it's pointing to an inaccessible location) in this case, which is weird but the fact :)

Weird O_o do you think you could make me an example project that reproduces this?

Weird O_o do you think you could make me an example project that reproduces this?

The Example project itself can reproduce the issue. You just need to open the menu. Tested on Xcode 13.0 (13A233)

Printing description of log_message->format:
(const char *) format = 0x000000000420c260 ""

Gotcha, thank you, I'll look into this and get back to you

@NSExceptional Should we merge my mitigation first and then find a better solution? I can patch my internal builds myself but maybe it's affecting everyone else as well.

Sorry, I've been on vacation for the last week. Looking into it now.

Pasting my commit message here:

entry->log_message.format appears to be garbage on iOS 15, and it doesn't look like it is ever really used in practice anyway, as far as I can tell. Thanks @matrush for pointing this out!

I opted to remove the usage of entry->log_message.format entirely without an iOS version check

Pasting my commit message here:

entry->log_message.format appears to be garbage on iOS 15, and it doesn't look like it is ever really used in practice anyway, as far as I can tell. Thanks @matrush for pointing this out!

I opted to remove the usage of entry->log_message.format entirely without an iOS version check

Thanks! I don't have any objection on removing that 👍