-
-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Crash on deallocated object (#4418)
Add a method to cause a sigsev crash by calling a method on a deallocated object.
- Loading branch information
1 parent
7cb89e0
commit eae2b59
Showing
6 changed files
with
39 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** | ||
* We need to this into an extra file so we can disable ARC with the -fno-objc-arc Compiler flag. | ||
* Otherwise, we can't call [NSObject release]. | ||
* | ||
*/ | ||
void callMessageOnDeallocatedObject(void); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#import "NoARCCrash.h" | ||
#import <Foundation/Foundation.h> | ||
|
||
void | ||
callMessageOnDeallocatedObject(void) | ||
{ | ||
NSObject *obj = [[NSObject alloc] init]; | ||
[obj release]; // Manually releasing in MRC, making `obj` a dangling pointer | ||
[obj description]; // Sending a message to a deallocated object causes a SIGSEGV | ||
} |
This file contains 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
This file contains 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