Skip to content
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

call method:"decompressFileAtPath:toPath:error:" crash #10

Open
QF-ZhouCheng opened this issue Jan 26, 2016 · 10 comments
Open

call method:"decompressFileAtPath:toPath:error:" crash #10

QF-ZhouCheng opened this issue Jan 26, 2016 · 10 comments

Comments

@QF-ZhouCheng
Copy link

when call the method and give a error parameters will crash.

like this:

NSError *decompressError = nil;
[DCTar decompressFileAtPath:strPath1 toPath:strPath2 error:&decompressError];

you can try it.

@daltoniam
Copy link
Owner

Ok, this doesn't give us anything to go off. Can you provide the crash you are getting? What is strPath1 and strPath2?

@QF-ZhouCheng
Copy link
Author

The code like this is ok:

[QFZIP decompressFileAtPath:strPath1 toPath:strPath2 error:nil];

and the code like this will crash:

NSError *decompressError = nil;
[QFZIP decompressFileAtPath:strPath1 toPath:strPath2 error:&decompressError];

Just give a error variable as the parameter.

@daltoniam

strPath1 = @"/var/mobile/Containers/Data/Application/A94B4EAC-5875-47AB-AC21-8437E72C6B78/Documents/Data/DownloadData.tar.gz"
strPath2 = @"/var/mobile/Containers/Data/Application/A94B4EAC-5875-47AB-AC21-8437E72C6B78/Documents/Data"

and crash info is:

Incident Identifier: 760F6AD2-6BC7-4E4C-A802-8FC60312ADF5
CrashReporter Key:   6971d8ae264d1f2f519b9ac7bbd6b1dba7a9a8a2
Hardware Model:      iPhone7,2
OS Version:          iPhone OS 8.3 (12F70)
Kernel version:      Darwin Kernel Version 14.0.0: Sun Mar 29 19:42:54 PDT 2015; root:xnu-2784.20.34~2/RELEASE_ARM64_T7000
Date:                2016-01-26 17:19:01 +0800
Exception Code:      0xd1510c8d
Reason:              Step count has rolled back!!

Thermal data unavailable

Frontmost process PID:    3194
Frontmost process PID:    54
Stackshot trace buffer size too small, trying again with 524288 bytes.
Jetsam Level:              0
Free Pages:            18232
Active Pages:         134789
Inactive Pages:        13616
Purgeable Pages:         796
Wired Pages:           52444
Speculative Pages:     17507
Throttled Pages:           0
File-backed Pages:     83496
Compressions:          92138
Decompressions:        13727
Compressor Size:       16028
Busy Buffer Count:         1
Pages Wanted:              0
Pages Reclaimed:           0

@daltoniam
Copy link
Owner

Hmm interesting. Do you have a stack trace? Not sure why providing a error would cause a crash, I don't see anything off hand that would cause that.

@QF-ZhouCheng
Copy link
Author

looks like not stack trace, I used NSURLSession to download the gzip file from server, and then decompress it, the stack trace just like this:

![screen shot 2016-01-27 at 11 43 36 am](https://cloud.githubusercontent.com/assets/13899656/12603209/89027468-c4eb-11e5-9903-b1276caf4f27.png)
![screen shot 2016-01-27 at 11 43 19 am](https://cloud.githubusercontent.com/assets/13899656/12603212/9164a6da-c4eb-11e5-917d-09c4a43c64d6.png)

@jinzhubaofu
Copy link

I got the same problem.

The error will trigger the crash.

Here is my stack trace.

image

image

image

@jinzhubaofu
Copy link

Hi, I guess this error passed down in a autoreleasepool maybe the reason.

https://github.com/daltoniam/tarkit/blob/master/DCTar.m#L315

I changed it to nill and it will stop crashing.

if(size == 0) {
   [@"" writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:nil];
}

@QF-ZhouCheng
Copy link
Author

@jinzhubaofu let me try.

@khzliu
Copy link

khzliu commented Sep 26, 2016

@jinzhubaofu it's helpful to me!

@fuji246
Copy link

fuji246 commented Aug 17, 2018

would be better to change that to

                if(size == 0) {
                    NSError *writeError;
                    BOOL ret = [@"" writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:&writeError];
                    if (!ret) {
                        NSLog(@"UNTAR - error during creating a directrory for a file - %@", writeError);
                    }
                }

@ConfusedVorlon
Copy link

for anyone coming to this from swift. The error param is automatically 'scooped' into the system, so you can't just set it to nil.

I ended up just creating an objective C helper

//DCTarHelper.h
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface DCTarHelper : NSObject

+(BOOL)decompressFileAtPath:(NSString*)filePath toPath:(NSString*)path;

@end

NS_ASSUME_NONNULL_END

//DCTarHelper.m
#import "DCTarHelper.h"
#import <tarkit/DCTar.h>

@implementation DCTarHelper

+(BOOL)decompressFileAtPath:(NSString*)filePath toPath:(NSString*)path {
    return [DCTar decompressFileAtPath:filePath toPath:path error:nil];
}

@end


which you can then call from Swift

DCTarHelper.decompressFile(atPath: source, toPath: destination)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants