rikyoz / bit7z

A C++ static library offering a clean and simple interface to the 7-zip shared libraries.
https://rikyoz.github.io/bit7z
Mozilla Public License 2.0
623 stars 113 forks source link

Crash at compressOut #50

Closed nolanjian closed 3 years ago

nolanjian commented 3 years ago

Describe the bug it crash just sometimes, but don't know why.

crash compressOut source paths: F:/01-绿色包备份/压缩包/DIYHomeV3.6.0测试/DIYHomeV3.17.0.03测试版本/Data/5/Scheme/jd004/4223E0B5-7B5E-423e-8C61-8148EAB96E43/X1000042001072/00/X1000042001072-16257152697900836.jx F:/01-绿色包备份/压缩包/DIYHomeV3.6.0测试/DIYHomeV3.17.0.03测试版本/Data/5/Scheme/jd004/4223E0B5-7B5E-423e-8C61-8148EAB96E43/X1000042001072/00/X1000042001072-16257152697900836.jpg F:/01-绿色包备份/压缩包/DIYHomeV3.6.0测试/DIYHomeV3.17.0.03测试版本/Data/5/Scheme/jd004/4223E0B5-7B5E-423e-8C61-8148EAB96E43/X1000042001072/00/X1000042001072-16257152697900836_H.json F:/01-绿色包备份/压缩包/DIYHomeV3.6.0测试/DIYHomeV3.17.0.03测试版本/Data/5/Scheme/jd004/4223E0B5-7B5E-423e-8C61-8148EAB96E43/X1000042001072/00/X1000042001072-16257152697900836_AttachH.json target path: F:/01-绿色包备份/压缩包/DIYHomeV3.6.0测试/DIYHomeV3.17.0.03测试版本/data/5/order/12924/47bb14b0d0274976ad87b7c08fabf3b4/4223E0B5-7B5E-423e-8C61-8148EAB96E43/X1000042001072-16257152697900836.zip

Expected behavior A clear and concise description of what you expected to happen.

Environment details (put an x in all the boxes that apply):

Additional context here is the call stack: vrfcore.dll!_VerifierStopMessageEx() Unknown vrfcore.dll!VfCoreRedirectedStopMessage(unsigned long,char ,unsigned long,char ,unsigned long,char ,unsigned long,char ,unsigned long,char ) Unknown vrfcore.dll!VfCoreRtlFreeHeap(void ,unsigned long,void ) Unknown oleaut32.dll!APP_DATA::FreeCachedMem(void ,unsigned long) Unknown oleaut32.dll!SysFreeStringImpl(unsigned short *) Unknown oleaut32.dll!_VariantClearWorker@4() Unknown oleaut32.dll!_VariantClear@4() Unknown 7z_21.dll!564e48db() Unknown 7z_21.dll![Frames below may be incorrect and/or missing, no symbols loaded for 7z_21.dll] Unknown

App.dll!compressOut(IOutArchive out_arc, ISequentialOutStream out_stream, bit7z::UpdateCallback update_callback) Line 42 C++ App.dll!bit7z::BitArchiveCreator::compressToFile(const std::wstring & out_file, bit7z::UpdateCallback update_callback) Line 267 C++ App.dll!bit7z::BitCompressor::compressOut(const std::vector<bit7z::filesystem::FSItem,std::allocator> & in_items, const std::wstring & out_file) Line 119 C++ App.dll!bit7z::BitCompressor::compress(const std::vector<std::wstring,std::allocator> & in_paths, const std::wstring & out_file) Line 42 C++ App.dll!bit7zCompressFiles(const std::vector<std::string,std::allocator> & vecFiles, const std::string & strTargetPath) Line 170 C++

nolanjian commented 3 years ago

This problem occur in a very low rate. Should I just keep one static Bit7zLibrary object in memory? Thx!

rikyoz commented 3 years ago

This problem occur in a very low rate.

Uhm odd. I noticed that you are using a slightly old version of bit7z (i.e., v3.0, while the latest one is v3.1.2). Could you try to use the latest version of bit7z and see if the problem persists?

Also, you are using an alpha version of 7-zip (v21.02), which I still didn't test to make sure it's compatible with bit7z. I'll try to verify that anyway.

Should I just keep one static Bit7zLibrary object in memory? Thx!

It shouldn't be a problem, but I didn't test using it as a static object. There shouldn't be problems in also using multiple Bit7zLibrary objects. But from the error logs, the Bit7zLibrary doesn't seem to be related to your issue. At least from what I can see.

nolanjian commented 3 years ago

@rikyoz thanks for your reply, this frew days I talks with my DEVs and QCs, this problem only occur when they attach AppVerifier to run our application with heaps options. Its the 7z.dll inside double free com memory somewhere, and detected by AppVerifier, then crash. For example, call SysFreeString(bstrTest) twice, its nothing wrong with commom running, but AppVerifier not think so. So, bit7z is excellent, I love it very much. Thanks for your help!

nolanjian commented 3 years ago

sorry that I reopen this issus, I make a simple demo with bit7z and the run attach by appverifier, it crash at HRESULT res = in_archive->Open( in_stream, nullptr, open_callback ); and here is the stop info: `======================================= VERIFIER STOP 00000007: pid 0x5478: Heap block already freed.

05C21000 : Heap handle for the heap owning the block.
0F5B0420 : Heap block being freed again.
00000030 : Size of the heap block.
00000000 : Not used

======================================= This verifier stop is not continuable. Process will be terminated when you use the `go' debugger command.

======================================= By curiosity, I alse use 7zip-cpp[https://github.com/getnamo/7zip-cpp](url) with another demo and run under appverifier, it doest crash, appverifier detect nothing. By the way, appverifier only set base->Heaps options on, Thx

rikyoz commented 3 years ago

Ok, so it's a problem of bit7z. I did some tests with AppVerifier, and it didn't find anything, but I used the most recent development version of bit7z, not the v3.1.2. Actually, now that I remember, some time ago I fixed a memory issue on the develop branch (commit 14af2c4bc5975f8a95a1feb8a8d3d174ba29943c). Unfortunately, I forgot to push the fix also to the master branch. I just did it, and I created a new version, v3.1.3 (https://github.com/rikyoz/bit7z/releases/tag/v3.1.3), which I hope will fix your issue.

nolanjian commented 3 years ago

It works! Thx!

rikyoz commented 3 years ago

Awesome, happy to have helped! Thank you for using bit7z! 👍