Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a crash caused by private class _PFResultASCIIString in iOS 14 #97

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
29 changes: 15 additions & 14 deletions FBRetainCycleDetector/Graph/FBObjectiveCGraphElement.mm
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
*/

#import "FBObjectiveCGraphElement+Internal.h"
#import <malloc/malloc.h>

#import <objc/message.h>
#import <objc/runtime.h>
@@ -39,22 +40,22 @@ - (instancetype)initWithObject:(id)object
{
if (self = [super init]) {
#if _INTERNAL_RCD_ENABLED
// We are trying to mimic how ObjectiveC does storeWeak to not fall into
// _objc_fatal path
// https://github.com/bavarious/objc4/blob/3f282b8dbc0d1e501f97e4ed547a4a99cb3ac10b/runtime/objc-weak.mm#L369

Class aCls = object_getClass(object);

BOOL (*allowsWeakReference)(id, SEL) =
(__typeof__(allowsWeakReference))class_getMethodImplementation(aCls, @selector(allowsWeakReference));

if (allowsWeakReference && (IMP)allowsWeakReference != _objc_msgForward) {
if (allowsWeakReference(object, @selector(allowsWeakReference))) {
// This is still racey since allowsWeakReference could change it value by now.
malloc_zone_t *zone = malloc_zone_from_ptr((__bridge void *)object);
if (zone) {
// We are trying to mimic how ObjectiveC does storeWeak to not fall into
// _objc_fatal path
// https://github.com/bavarious/objc4/blob/3f282b8dbc0d1e501f97e4ed547a4a99cb3ac10b/runtime/objc-weak.mm#L369
Class aCls = object_getClass(object);
BOOL (*allowsWeakReference)(id, SEL) =
(__typeof__(allowsWeakReference))class_getMethodImplementation(aCls, @selector(allowsWeakReference));
if (allowsWeakReference && (IMP)allowsWeakReference != _objc_msgForward) {
if (allowsWeakReference(object, @selector(allowsWeakReference))) {
// This is still racey since allowsWeakReference could change it value by now.
_object = object;
}
} else {
_object = object;
}
} else {
_object = object;
}
#endif
_namePath = namePath;