-
Notifications
You must be signed in to change notification settings - Fork 134
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
ios: bugfix for wrong userInfo #68
Open
fatfatson
wants to merge
2
commits into
a7ul:master
Choose a base branch
from
fatfatson:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+33
−9
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,37 @@ | ||
#import "ReactNativeExceptionHandler.h" | ||
|
||
#import <mach-o/dyld.h> | ||
|
||
// CONSTANTS | ||
NSString * const RNUncaughtExceptionHandlerSignalExceptionName = @"RNUncaughtExceptionHandlerSignalExceptionName"; | ||
NSString * const RNUncaughtExceptionHandlerSignalKey = @"RNUncaughtExceptionHandlerSignalKey"; | ||
NSString * const RNUncaughtExceptionHandlerAddressesKey = @"RNUncaughtExceptionHandlerAddressesKey"; | ||
volatile int32_t RNUncaughtExceptionCount = 0; | ||
const int32_t RNUncaughtExceptionMaximum = 10; | ||
const NSInteger RNUncaughtExceptionHandlerSkipAddressCount = 4; | ||
const NSInteger RNUncaughtExceptionHandlerReportAddressCount = 5; | ||
const NSInteger RNUncaughtExceptionHandlerSkipAddressCount = 0; | ||
const NSInteger RNUncaughtExceptionHandlerReportAddressCount = 15; | ||
|
||
|
||
void getSlide(long* pheader,long* pslide) { | ||
for (uint32_t i = 0; i < _dyld_image_count(); i++) { | ||
if (_dyld_get_image_header(i)->filetype == MH_EXECUTE) { | ||
long slide = _dyld_get_image_vmaddr_slide(i); | ||
const struct mach_header* header = _dyld_get_image_header(i); | ||
if(pheader)*pheader=header; | ||
if(pslide)*pslide=slide; | ||
|
||
return; | ||
} | ||
} | ||
} | ||
|
||
long letMeCrash(){ | ||
int* p = 1234; | ||
*p = 1; | ||
return 0; | ||
} | ||
long funcImyourDD(){ if(RNUncaughtExceptionCount%2) printf("funcImyourDD11");else printf("funcImyourDD22"); return letMeCrash();} | ||
long funcFuckyourBB(){ if(RNUncaughtExceptionCount%2) printf("funcFuckyourBB11");else printf("funcFuckyourBB22"); return RNUncaughtExceptionCount+funcImyourDD();} | ||
long funcAreyouSB(){ if(RNUncaughtExceptionCount%2) printf("funcAreyouSB11");else printf("funcAreyouSB22"); return RNUncaughtExceptionCount+funcFuckyourBB();} | ||
|
||
@implementation ReactNativeExceptionHandler | ||
|
||
|
@@ -59,8 +81,9 @@ - (dispatch_queue_t)methodQueue | |
// ==================================== | ||
|
||
RCT_EXPORT_MODULE(); | ||
|
||
// METHOD TO INITIALIZE THE EXCEPTION HANDLER AND SET THE JS CALLBACK BLOCK | ||
RCT_EXPORT_METHOD(raiseTestNativeError) { NSLog(@"RAISING A TEST EXCEPTION"); [NSException raise:@"TEST EXCEPTION" format:@"THIS IS A TEST EXCEPTION"]; } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned on the issue before . I dont think we should add raiseTestNative Error as part of this module. Could you please remove these. |
||
RCT_EXPORT_METHOD(raiseTestNativeErrorCXX) { NSLog(@"RAISING A TEST EXCEPTION"); funcAreyouSB(); } | ||
// METHOD TO INITIALIZE THE EXCEPTION HANDLER AND SET THE JS CALLBACK BLOCK | ||
RCT_EXPORT_METHOD(setHandlerforNativeException:(RCTResponseSenderBlock)callback) | ||
{ | ||
jsErrorCallbackBlock = ^(NSException *exception, NSString *readeableException){ | ||
|
@@ -199,10 +222,7 @@ void SignalHandler(int signal) | |
[NSString stringWithFormat: | ||
NSLocalizedString(@"Signal %d was raised.", nil), | ||
signal] | ||
userInfo: | ||
[NSDictionary | ||
dictionaryWithObject:[NSNumber numberWithInt:signal] | ||
forKey:RNUncaughtExceptionHandlerSignalKey]] | ||
userInfo:userInfo] | ||
waitUntilDone:YES]; | ||
} | ||
|
||
|
@@ -219,6 +239,10 @@ + (NSArray *)backtrace | |
|
||
int i; | ||
NSMutableArray *backtrace = [NSMutableArray arrayWithCapacity:frames]; | ||
|
||
long header=0,slide=0; | ||
getSlide(&header, &slide); | ||
[backtrace addObject:[NSString stringWithFormat:@"slideheader: 0x%X",header]]; | ||
for ( | ||
i = RNUncaughtExceptionHandlerSkipAddressCount; | ||
i < RNUncaughtExceptionHandlerSkipAddressCount + | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also please remove these test functions as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, I have opened a new PR.
I had thought that only the commits before opening are visible, so I commit my own modify after open it, but it's not the truth. now I make a special branch for this, hope it's ok this time~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by the way , except those test functions, getting and saving the
slide
is useful for symbol address translation, would you like it to be merged?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I want to merge everything except the test functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove only the test functions.