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

ZPAQ Segfault with incompressible blocks #244

Open
pete4abw opened this issue Jul 3, 2023 · 0 comments
Open

ZPAQ Segfault with incompressible blocks #244

pete4abw opened this issue Jul 3, 2023 · 0 comments

Comments

@pete4abw
Copy link
Contributor

pete4abw commented Jul 3, 2023

Setting a difficult to compress file and suppressing threshold testing with ZPAQ causes a segfault. Solution is to add 2% to the destination buffer like we did with lzma. Thanks to @Merculous who pointed this out to lrzip-next.

diff --git a/stream.c b/stream.c
index 7093ca9..bce1cd5 100644
--- a/stream.c
+++ b/stream.c
@@ -164,7 +164,7 @@ static int zpaq_compress_buf(rzip_control *control, struct compress_thread *cthr
        if (!lz4_compresses(control, cthread->s_buf, cthread->s_len))
                return 0;
 
-       c_size = round_up_page(control, cthread->s_len + 10000);
+       c_size = round_up_page(control, cthread->s_len * 1.02);
        c_buf = malloc(c_size);
        if (!c_buf) {
                print_err("Unable to allocate c_buf in zpaq_compress_buf\n");

After this fix, the file compression completes (although compression is lousy :-) ).
See This discussion for some color.

$ ./lrzip -vvz -L1 -T ../zpaq.tst
The following options are in effect for this COMPRESSION.
Threading is ENABLED. Number of CPUs detected: 8
Detected 16538480640 bytes ram
Compression level 1
Nice Value: 19
Show Progress
Max Verbose
Temporary Directory set as: /tmp/
Compression mode is: ZPAQ. LZ4 Compressibility testing disabled
Heuristically Computed Compression Window: 105 = 10500MB
Storage time in seconds 1392478474
Output filename is: ../zpaq.tst.lrz
File size: 1073741824
Succeeded in testing 1073741824 sized mmap for rzip pre-processing
Will take 1 pass
Chunk size: 1073741824
Byte width: 4
Succeeded in testing 2130706432 sized malloc for back end compression
Using up to 9 threads to compress up to 119304648 bytes each.
Beginning rzip pre-processing phase
hashsize = 131072.  bits = 17. 2MB
Starting sweep for mask 15
Starting sweep for mask 31
Starting sweep for mask 63
Starting sweep for mask 127
Starting sweep for mask 255
Starting sweep for mask 511
Starting sweep for mask 1023
Starting sweep for mask 2047
Starting sweep for mask 4095
Starting sweep for mask 8191
87380 total hashes -- 9 in primary bucket (0.010%)
Starting thread 0 to compress 119304648 bytes from stream 1
Starting thread 1 to compress 119304648 bytes from stream 1
Starting thread 2 to compress 119304648 bytes from stream 1
Starting thread 3 to compress 119304648 bytes from stream 1
Starting thread 4 to compress 119304648 bytes from stream 1%  
Starting thread 5 to compress 119304648 bytes from stream 1     5:0%  
Starting thread 6 to compress 119304648 bytes from stream 1             6:0%  
Starting thread 7 to compress 119304648 bytes from stream 1                     7:0%  
Malloced 5512826880 for checksum ckbuf                                                  8:0%  
Starting thread 8 to compress 49162 bytes from stream 0
Incompressible block    ZPAQ    1:90%   2:90%   3:100%  4:90%   5:90%   6:90%   7:90%   8:90%   9:100%  
Segmentation fault (core dumped)
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

1 participant