Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions stdlib/public/runtime/HeapObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,17 @@ void swift::swift_deallocPartialClassInstance(HeapObject *object,
// Destroy ivars
auto *classMetadata = _swift_getClassOfAllocated(object)->getClassObject();
assert(classMetadata && "Not a class?");

#if SWIFT_OBJC_INTEROP
// If the object's class is already pure ObjC class, just release it and move
// on. There are no ivar destroyers. This avoids attempting to mutate
// placeholder objects statically created in read-only memory.
if (classMetadata->isPureObjC()) {
objc_release((id)object);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. Looks like this file somehow doesn't include the definition of id; seems odd that it's got objc_release(), but not id.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh silly me, this needs to be guarded by OBJC_INTEROP too.

return;
}
#endif

while (classMetadata != metadata) {
#if SWIFT_OBJC_INTEROP
// If we have hit a pure Objective-C class, we won't see another ivar
Expand Down