This is an archive of the discontinued LLVM Phabricator instance.

[lsan] Be more conservative in SuspendedThreadsListMac::GetRegistersAndSP
ClosedPublic

Authored by lgrey on Jun 15 2023, 1:52 PM.

Details

Summary

Currently, we only return REGISTERS_UNAVAILABLE_FATAL if we receive KERN_INVALID_ARGUMENT from thread_status. In reality, there are other possible return values (MACH_SEND_INVALID_DEST for example) that make it dangerous to read memory. This can be demonstrated by running create_thread_leak.cpp in standalone mode where it will appear to hang due to a EXC_BAD_ACCESS while scanning the stack.

This change reverses the current logic to treat MIG_ARRAY_TOO_LARGE as non-fatal, and all other errors as fatal.

Diff Detail

Event Timeline

lgrey created this revision.Jun 15 2023, 1:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2023, 1:52 PM
Herald added a subscriber: Enna1. · View Herald Transcript
lgrey requested review of this revision.Jun 15 2023, 1:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2023, 1:52 PM
Herald added a subscriber: Restricted Project. · View Herald Transcript
lgrey added a reviewer: yln.Jun 21 2023, 7:42 AM

yln@, looks like kubamracek@ hasn't been active recently, can you take a look? :)

aeubanks accepted this revision.Jun 23 2023, 11:08 AM
aeubanks added a subscriber: aeubanks.

makes sense, as long as all the tests pass with this change

This revision is now accepted and ready to land.Jun 23 2023, 11:08 AM
hans accepted this revision.Jun 27 2023, 4:22 AM
hans added a subscriber: hans.

Looks reasonable to me too.

hans added a comment.Jun 28 2023, 1:39 AM

It seems Leonard is out at the moment, so I'll go ahead and commit this on his behalf.