[Lldb-commits] [PATCH] D127252: [lldb] Use objc_getRealizedClassList_trylock if available

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 7 14:11:05 PDT 2022


JDevlieghere created this revision.
JDevlieghere added a reviewer: jingham.
Herald added a project: All.
JDevlieghere requested review of this revision.
Herald added a project: LLDB.

In order to avoid stranding the Objective-C runtime lock, we switched from `objc_copyRealizedClassList` to its non locking variant `objc_copyRealizedClassList_nolock`. Not taking the lock was relatively safe because we run this expression on one thread only, but it was still possible that someone was in the middle of modifying this list while we were trying to read it. Worst case that would result in a crash in the inferior without side-effects and we'd unwind and try again later.

With the introduction of macOS Ventura, we can use `objc_getRealizedClassList_trylock` instead. It has semantics similar to `objc_copyRealizedClassList_nolock`, but instead of not locking at all, the function returns if the lock is already taken, which avoids the aforementioned crash without stranding the Objective-C runtime lock. Because LLDB gets to allocate the underlying memory we also avoid stranding the malloc lock.

rdar://89373233


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127252

Files:
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
  lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127252.434941.patch
Type: text/x-patch
Size: 14253 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220607/0e07257c/attachment.bin>


More information about the lldb-commits mailing list