[Lldb-commits] [lldb] [lldb] Objective-C runtime: Work around a bug in the shared cache builder (PR #130209)
Adrian Prantl via lldb-commits
lldb-commits at lists.llvm.org
Thu Mar 6 16:35:57 PST 2025
https://github.com/adrian-prantl created https://github.com/llvm/llvm-project/pull/130209
where it can overflow a 2GB offset by just a little bit by applying a heuristic.
rdar://145888306
>From a6caecd1e1bae614579783ac1952e999eae5959d Mon Sep 17 00:00:00 2001
From: Adrian Prantl <aprantl at apple.com>
Date: Thu, 6 Mar 2025 16:33:35 -0800
Subject: [PATCH] [lldb] Objective-C runtime: Work around abug in the shared
cache builder
where it can overflow a 2GB offset by just a little bit by applying a
heuristic.
rdar://145888306
---
.../ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
index ff17028e6662a..2dde490b549fe 100644
--- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
@@ -458,7 +458,14 @@ __lldb_apple_objc_v2_get_shared_cache_class_info (void *objc_opt_ro_ptr,
if (objc_opt->version == 16)
{
- const objc_clsopt_v16_t* clsopt = (const objc_clsopt_v16_t*)((uint8_t *)objc_opt + objc_opt_v16->largeSharedCachesClassOffset);
+ int32_t large_offset = objc_opt_v16->largeSharedCachesClassOffset;
+ const objc_clsopt_v16_t* clsopt = (const objc_clsopt_v16_t*)((uint8_t *)objc_opt + large_offset);
+ // Work around a bug in some version shared cache builder where the offset overflows 2GiB.
+ uint32_t unsigned_offset = (uint32_t)large_offset;
+ if (unsigned_offset > 0x7fffffff && unsigned_offset < 0x82000000) {
+ clsopt = (const objc_clsopt_v16_t*)((uint8_t *)objc_opt + unsigned_offset);
+ DEBUG_PRINTF("warning: applying largeSharedCachesClassOffset overflow workaround!\n");
+ }
const size_t max_class_infos = class_infos_byte_size/sizeof(ClassInfo);
DEBUG_PRINTF("max_class_infos = %llu\n", (uint64_t)max_class_infos);
More information about the lldb-commits
mailing list