Skip to content

Commit

Permalink
[ORC-RT] Fix objc selector corruption
Browse files Browse the repository at this point in the history
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
  • Loading branch information
benlangmuir committed Oct 27, 2021
1 parent d378a0f commit beb3d48
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler-rt/lib/orc/macho_platform.cpp
Expand Up @@ -112,10 +112,10 @@ Error registerObjCSelectors(
if (auto Err = validatePointerSectionExtent("__objc_selrefs", ObjCSelRefs))
return Err;

for (uintptr_t SelEntry : ObjCSelRefs.toSpan<uintptr_t>()) {
for (uintptr_t &SelEntry : ObjCSelRefs.toSpan<uintptr_t>()) {
const char *SelName = reinterpret_cast<const char *>(SelEntry);
auto Sel = sel_registerName(SelName);
*reinterpret_cast<SEL *>(SelEntry) = Sel;
*reinterpret_cast<SEL *>(&SelEntry) = Sel;
}
}

Expand Down

0 comments on commit beb3d48

Please sign in to comment.