Skip to content

Commit beb3d48

Browse files
committed
[ORC-RT] Fix objc selector corruption
We were writing a pointer to a selector string into the contents of a string instead of overwriting the pointer to the string, leading to corruption. This was causing non-deterministic failures of the 'trivial-objc-methods' test case. Differential Revision: https://reviews.llvm.org/D112671
1 parent d378a0f commit beb3d48

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler-rt/lib/orc/macho_platform.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,10 @@ Error registerObjCSelectors(
112112
if (auto Err = validatePointerSectionExtent("__objc_selrefs", ObjCSelRefs))
113113
return Err;
114114

115-
for (uintptr_t SelEntry : ObjCSelRefs.toSpan<uintptr_t>()) {
115+
for (uintptr_t &SelEntry : ObjCSelRefs.toSpan<uintptr_t>()) {
116116
const char *SelName = reinterpret_cast<const char *>(SelEntry);
117117
auto Sel = sel_registerName(SelName);
118-
*reinterpret_cast<SEL *>(SelEntry) = Sel;
118+
*reinterpret_cast<SEL *>(&SelEntry) = Sel;
119119
}
120120
}
121121

0 commit comments

Comments
 (0)