mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Runtime] Fix swift_retainCount for deiniting objects and BridgeObject tagged values. Make swift_bridgeObjectRetain/Release bail out early for tagged values.
The Allocations Instrument overrides swift_retain with a function that records the retain count by calling swift_retainCount. Its assert for bits.getIsDeiniting() is incorrect in that case, so remove it. The recent change to ObjC tagged pointer bits on x86-64 also caused the various bridgeObjectRetain/Release functions to call through to swift_retain for BridgeObject tagged values on Mac. swift_retain ignored those values so there was no functional change, except when Instruments overrode it and passed them to swift_retainCount, which tried to dereference them and crashed. Modify bridgeObjectRetain/Release to bail out early again. Also modify swift_retainCount to ignore those values in case anything else expects retainCount to work on any pointer swift_retain accepts. rdar://problem/45102538
This commit is contained in:
@@ -365,7 +365,9 @@ void swift::swift_nonatomic_release_n(HeapObject *object, uint32_t n) {
|
||||
}
|
||||
|
||||
size_t swift::swift_retainCount(HeapObject *object) {
|
||||
return object->refCounts.getCount();
|
||||
if (isValidPointerForNativeRetain(object))
|
||||
return object->refCounts.getCount();
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t swift::swift_unownedRetainCount(HeapObject *object) {
|
||||
|
||||
Reference in New Issue
Block a user