Last active
March 3, 2018 23:47
-
-
Save Raztor0/e96f54bb522aa4ad2a8b5b84ef94b0b9 to your computer and use it in GitHub Desktop.
NSJSONSerialization EXC_BAD_ACCESS KERN_INVALID_ADDRESS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (void)load { | |
static NSMutableDictionary *myMutableDict; | |
static NSDictionary *myDict; | |
myMutableDict = [NSMutableDictionary dictionaryWithDictionary:@{}]; | |
myDict = @{@"sub_dict" : myMutableDict}; | |
/* Hop on a background thread */ | |
dispatch_async(dispatch_get_global_queue(0, 0), ^{ | |
/* Constantly mutate the mutable dictionary */ | |
while (YES) { | |
[myMutableDict setObject:[[NSUUID UUID] UUIDString] forKey:[[NSUUID UUID] UUIDString]]; | |
} | |
}); | |
while (YES) { | |
/* Constantly try serializing the non-mutable outer dictionary */ | |
/* This line will eventually result in EXC_BAD_ACCESS KERN_INVALID_ADDRESS */ | |
NSData * __unused data = [NSJSONSerialization dataWithJSONObject:myDict options:kNilOptions error:nil]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment