Bug 509201

Summary: KArchive fails to extract 7z archives that use the BCJ2 filter.
Product: [Frameworks and Libraries] frameworks-karchive Reporter: Azhar Momin <azhar-momin>
Component: generalAssignee: KIO Bugs <kio-bugs-null>
Status: REPORTED ---    
Severity: normal CC: kdelibs-bugs-null
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Azhar Momin 2025-09-06 17:16:01 UTC
SUMMARY

KArchive fails to extract 7z archives that use the BCJ2 filter.

STEPS TO REPRODUCE
1. Create a test archive with BCJ2:
   `7z a archive.7z /usr/bin/ls -m0=BCJ2 -m1=LZMA2 -m2=LZMA2 -m3=LZMA2`
2. Attempt to extract using KArchive:
   `archive.directory()->copyTo()`
3. Extraction fails with an assertion error:
./build/karchivetest archive.7z
ASSERT: "n == currentChunkSize" in /home/azhar/Projects/KArchive/src/karchive.cpp, line 871
[1] 10321 IOT instruction (core dumped) ./build/karchivetest archive.7z`

OBSERVED RESULT
Extraction fails with assertion error.

EXPECTED RESULT
Archive should extract successfully.

SOFTWARE/OS VERSIONS
Distro: openSUSE Tumbleweed 20250820
KDE Plasma: 6.4.4
KDE Frameworks: 6.17.0
Qt: 6.9.2
Comment 1 Azhar Momin 2025-09-06 17:22:03 UTC
Another problem I observed: when creating a 7z archive with the BCJ2 filter using small text content (instead of a binary), extraction does not crash but produces an incomplete file with extra garbage data prepended, this may or may not be the same problem:

➜  Testing echo 'Hello, World!' | 7z a 7z_coder_test_bcj2.7z -m0=bcj2 -m1=lzma2 -m2=lzma2 -m3=lzma2 -sihello.txt

7-Zip (z) 24.09 (x64) : Copyright (c) 1999-2024 Igor Pavlov : 2024-11-29
 64-bit locale=en_US.UTF-8 Threads:8 OPEN_MAX:524288, ASM

Creating archive: 7z_coder_test_bcj2.7z

Add new data to archive: 1 file


Files read from disk: 1
Archive size: 185 bytes (1 KiB)
Everything is Ok
➜  Testing ./build/karchivetest 7z_coder_test_bcj2.7z
Archive directory copied successfully
➜  Testing xxd out/hello.txt
00000000: 0100 1101 000d 4865 6c6c 6f2c 2057       ......Hello, W