NSLogger icon indicating copy to clipboard operation
NSLogger copied to clipboard

[CRASH] crash when opening .nsloggerrawdata in Desktop Viewer

Open quzongyao opened this issue 3 years ago • 3 comments

macOS: Big Sur 11.1 Desktop Viewer: 1.9.7

Client nslogger: installed by cocoapods and version is 1.9.7

How to reproduce:

  1. open an nsloggerrawdata file recorded in my iOS app
  2. open the file in Desktop Viewer
  3. 💣

Reproducing Rate: 100%

I also tried to build the Desktop Viewer myself from the master branch and crash is occurring.

And after the following change, no crash any more.

in LoggerDocument.m
- (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError {

LINE 312
-			NSData *subset = [NSData dataWithBytesNoCopy:(unsigned char *)p + 4 length:length];
+			NSData *subset = [NSData dataWithBytes:(unsigned char *)p + 4 length:length];

I checked the code, p is from the input param, and dataWithBytesNoCopy will hand the ownership from to subset. This could cause the input param data to be deallocated twice.

Please check my analysis, thank you.

Sorry I don't have much time to make a PR.

quzongyao avatar Mar 05 '21 09:03 quzongyao

Same issue here. It works with 1.9.0 version, not with version >= 1.9.5

Deub27 avatar May 08 '21 11:05 Deub27

should be: NSData *subset = [NSData dataWithBytesNoCopy:(unsigned char *)p + 4 length:length freeWhenDone:NO];

nk-contorra avatar Jan 19 '22 19:01 nk-contorra

Did you compile the package yourself?

aolan avatar Jun 14 '22 09:06 aolan