OlehKulykov / PLzmaSDK

PLzmaSDK is (Portable, Patched, Package, cross-P-latform) Lzma SDK.
Other
85 stars 25 forks source link

Crash decoding an archive in String function (Swift 1.1.3) #13

Closed afedor closed 2 years ago

afedor commented 3 years ago

Using Swift 1.1.3 version, I get this crash decoding an archive. Note that the MacOS finder opens the archive correctly, the old LzmaSDKObjC opened it as well, although it was missing some files.

(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = Fatal error: Unexpectedly found nil while unwrapping an Optional value
    frame #0: 0x00000001ad10bd84 libswiftCore.dylib`_swift_runtime_on_report
    frame #1: 0x00000001ad184de8 libswiftCore.dylib`_swift_stdlib_reportFatalErrorInFile + 192
    frame #2: 0x00000001acdc0a0c libswiftCore.dylib`closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in closure #1 (Swift.UnsafeBufferPointer<Swift.UInt8>) -> () in Swift._assertionFailure(_: Swift.StaticString, _: Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 404
    frame #3: 0x00000001acdc0048 libswiftCore.dylib`Swift._assertionFailure(_: Swift.StaticString, _: Swift.StaticString, file: Swift.StaticString, line: Swift.UInt, flags: Swift.UInt32) -> Swift.Never + 396
  * frame #4: 0x000000010508d314 PLzmaSDK-Dynamic`String.init(ptr=0x6000033c2850) at String+Plzma.swift:34:53
    frame #5: 0x000000010507b318 PLzmaSDK-Dynamic`closure #2 in Decoder.init(ctx=0x600000166e80, utf8CString=0x6000033c2850, progress=0x3fd9bbd30c4b7e1c) at Decoder.swift:280:58
    frame #6: 0x000000010507b38c PLzmaSDK-Dynamic`@objc closure #2 in Decoder.init(stream:fileType:delegate:) at <compiler-generated>:0
    frame #7: 0x000000010515a6f4 PLzmaSDK-Dynamic`plzma::Progress::ReportData::report(this=0x000000016d69fa28) const at plzma_progress.hpp:63:21
    frame #8: 0x000000010515ace4 PLzmaSDK-Dynamic`plzma::Progress::setPath(this=0x00006000039ba640, path=0x000000016d69fcc0) at plzma_progress.cpp:173:20
    frame #9: 0x00000001051455b4 PLzmaSDK-Dynamic`plzma::ExtractCallback::getExtractStream(this=0x000000012de94700, index=28, outStream=0x000000016d69fe30) at plzma_extract_callback.cpp:187:20
    frame #10: 0x0000000105145930 PLzmaSDK-Dynamic`plzma::ExtractCallback::GetStream(this=0x000000012de94700, index=28, outStream=0x000000016d69fe30, askExtractMode=0) at plzma_extract_callback.cpp:208:42
    frame #11: 0x00000001050ca168 PLzmaSDK-Dynamic`NArchive::N7z::CFolderOutStream::OpenFile(this=0x0000600002fecb90, isCorrupted=false) at 7zExtract.cpp:93:3
    frame #12: 0x00000001050ca790 PLzmaSDK-Dynamic`NArchive::N7z::CFolderOutStream::Write(this=0x0000600002fecb90, data=0x00000002c5fa8407, size=130169, processedSize=0x000000016d69ff08) at 7zExtract.cpp:195:5
    frame #13: 0x000000010510f3cc PLzmaSDK-Dynamic`WriteStream(stream=0x0000600002fecb90, data=0x00000002c5bc8080, size=4194304) at StreamUtils.cpp:48:27
    frame #14: 0x00000001051026a4 PLzmaSDK-Dynamic`MyWrite(pp=0x000000016d6a0188, data=0x00000002c5bc8080, size=4194304) at CWrappers.cpp:93:14
    frame #15: 0x00000001050a25d8 PLzmaSDK-Dynamic`Lzma2Dec_Decode_ST(p=0x000000011a5b7a80) at Lzma2DecMt.c:748:26
    frame #16: 0x00000001050a2210 PLzmaSDK-Dynamic`Lzma2DecMt_Decode(pp=0x000000011a5b7a80, prop='\x1c', props=0x000000016d6a01c8, outStream=0x000000016d6a0188, outDataSize=0x0000600002fe9378, finishMode=1, inStream=0x000000016d6a01a8, inProcessed=0x000000016d6a0160, isMT=0x000000016d6a015c, progress=0x000000016d6a0170) at Lzma2DecMt.c:949:16
    frame #17: 0x0000000105116b5c PLzmaSDK-Dynamic`NCompress::NLzma2::CDecoder::Code(this=0x0000600003e71050, inStream=0x0000600000165fb0, outStream=0x0000600002fecb90, inSize=0x0000600000eefd90, outSize=0x0000600002fe9378, progress=0x0000600002fefca0) at Lzma2Decoder.cpp:152:9
    frame #18: 0x00000001050ec134 PLzmaSDK-Dynamic`NCoderMixer2::CMixerST::Code(this=0x00006000039b8780, inStreams=0x0000600000eec660, outStreams=0x000000016d6a0850, progress=0x0000600002fefca0, dataAfterEnd_Error=0x000000016d6a0c9f) at CoderMixer2.cpp:776:28
    frame #19: 0x00000001050c0654 PLzmaSDK-Dynamic`NArchive::N7z::CDecoder::Decode(this=0x000000016d6a0d10, inStream=0x00006000023fcb00, startPos=32, folders=0x000000011a5c69c8, folderIndex=0, unpackSize=0x000000016d6a0d00, outStream=0x0000600002fecb90, compressProgress=0x0000600002fefca0, inStreamMainRes=0x0000000000000000, dataAfterEnd_Error=0x000000016d6a0c9f, getTextPassword=0x000000012de94700, isEncrypted=0x000000016d6a0cb7, passwordIsDefined=0x000000016d6a0cb6, password=0x000000016d6a0ca0) at 7zDecode.cpp:557:20
    frame #20: 0x00000001050cafe8 PLzmaSDK-Dynamic`NArchive::N7z::CHandler::Extract(this=0x000000011a5c6910, indices=0x000000016d6a0f58, numItems=63, testModeSpec=0, extractCallbackSpec=0x000000012de94700) at 7zExtract.cpp:359:32
    frame #21: 0x00000001051462c4 PLzmaSDK-Dynamic`plzma::ExtractCallback::process(this=0x000000012de94700) at plzma_extract_callback.cpp:356:67
    frame #22: 0x0000000105146640 PLzmaSDK-Dynamic`plzma::ExtractCallback::process(this=0x000000012de94700, mode=0, path=0x0000600000d20020, itemsFullPath=true) at plzma_extract_callback.cpp:395:9
    frame #23: 0x0000000105137608 PLzmaSDK-Dynamic`bool plzma::DecoderImpl::process<NArchive::NExtract::NAskMode::$_0, plzma::Path const&, bool const&>(this=0x0000600003a5c280, args=0x000000016d6a1488, args=0x0000600000d20020, args=0x000000016d6a148f) at plzma_decoder_impl.hpp:104:30
    frame #24: 0x00000001051374a0 PLzmaSDK-Dynamic`plzma::DecoderImpl::extract(this=0x0000600003a5c280, path=0x0000600000d20020, usingItemsFullPath=true) at plzma_decoder_impl.cpp:105:16
    frame #25: 0x0000000105139b24 PLzmaSDK-Dynamic`::plzma_decoder_extract_all_items_to_path(decoder=0x000000016d6a1578, path=0x000000016d6a1568, items_full_path=true) at plzma_decoder_impl.cpp:290:57
    frame #26: 0x0000000105079f24 PLzmaSDK-Dynamic`Decoder.extract(path=0x0000600000d22cc0, itemsFullPath=true, self=0x0000600000d23940) at Decoder.swift:142:22
OlehKulykov commented 3 years ago

Hi, please provide a test project for a Swift 1.1.3, since a crash is in a creating of the string with non-nil c_str pointer.

afedor commented 3 years ago

Here's a test project. But the actual 7z file I have that is corrupt is too large to attach here. But I could email it or upload it somewhere else. LzmaTest.zip

OlehKulykov commented 2 years ago

This lib supports only Swift >= 5.x and not a 'Swift 1.1.3'