Skip to content

zekunyan/OutParameterPointerCrashOnXcode8

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 

Example code for out parameter pointer EXC_BAD_ACCESS crash on Xcode 8

Code:

// main.m
#import <Foundation/Foundation.h>
#import <CoreFoundation/CoreFoundation.h>

@interface TestClass : NSObject
@end

@implementation TestClass

+ (void)runTest {
    NSMutableArray *array = [NSMutableArray new];
    [TestClass testFunc:&array];
    [TestClass testFunc:&array];
    NSLog(@"array: %@", array);
}

+ (void)testFunc:(NSMutableArray **)array {
}

@end

int main(int argc, const char * argv[]) {
    @autoreleasepool {
        [TestClass runTest];
    }
    return 0;
}

Build on Release configuration.

On Xcode 8, it will crash.

On Xcode 7, it works normal.

Use Hopper disassembler to check:

img

About

Example code for out parameter pointer EXC_BAD_ACCESS crash on Xcode 8

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages