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

Lzma Uncompression fails with "Memory usage limit was reached" #1

Closed
pmqs opened this issue Nov 6, 2019 · 6 comments
Closed

Lzma Uncompression fails with "Memory usage limit was reached" #1

pmqs opened this issue Nov 6, 2019 · 6 comments
Assignees

Comments

@pmqs
Copy link
Owner

pmqs commented Nov 6, 2019

Seeing a number of cpantesters failures where the common denominator is the lzma error message Memory usage limit was reached

Below is a typical failure

PERL_DL_NONLAZY=1 "/home/sand/src/perl/repoperls/installed-perls/host/k93msid/v5.30.0/ac75/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/000prereq.t ......... ok
t/001main.t ........... ok

#     Failed test (t/010main-unzip.t at line 385)
#          got: ''
#     expected: 'abcd1'

#     Failed test (t/010main-unzip.t at line 411)
#          got: undef
#     expected: '5'

#     Failed test (t/010main-unzip.t at line 412)
#          got: '0'
#     expected: '5'
# Uncompression Error: Memory usage limit was reached
@pmqs
Copy link
Owner Author

pmqs commented Nov 6, 2019

Some discussion on memory usage at the XZ Utils forum here

@pmqs
Copy link
Owner Author

pmqs commented Nov 6, 2019

This code leaks memory

use strict ;
use warnings ;

use Archive::Zip::SimpleZip qw(:all) ;
use Archive::Zip::SimpleUnzip ;

my $zipfile;
my $zip = new Archive::Zip::SimpleZip \$zipfile, Method =>ZIP_CM_LZMA 
    or die "xxx\n" ;

$zip->addString("hello workld", Name => "fred");
$zip->addString("hello workld", Name => "joe");
$zip->close();

my $unzip = new Archive::Zip::SimpleUnzip(\$zipfile)
    or die "Cannot opwen\n" ;

while (1)
{
    my $x = $unzip->content("joe");
    my $y = $unzip->content("fred");
}

@pmqs pmqs changed the title Lzma Uncompression fails with Memory usage limit was reached Lzma Uncompression fails with "Memory usage limit was reached" Nov 6, 2019
@pmqs
Copy link
Owner Author

pmqs commented Nov 7, 2019

Valgrind sees a leak

==15500== 213,808 bytes in 1,909 blocks are definitely lost in loss record 2,403 of 2,408
==15500==    at 0x483874F: malloc (vg_replace_malloc.c:299)
==15500==    by 0x6BDB096: lzma_lzma_props_decode (lzma_decoder.c:1042)
==15500==    by 0x6BBBE45: setupFilters (in /media/paul/Linux-Shared/base/perl/ext/Gzip/blib/arch/auto/Compress/Raw/Lzma/Lzma.so)
==15500==    by 0x6BBC08C: XS_Compress__Raw__Lzma_lzma_raw_decoder (in /media/paul/Linux-Shared/base/perl/ext/Gzip/blib/arch/auto/Compress/Raw/Lzma/Lzma.so)
==15500==    by 0x4B5887: Perl_pp_entersub (in /media/paul/Linux-Shared/base/perl/install/bin/perl)
==15500==    by 0x4AE2C2: Perl_runops_standard (in /media/paul/Linux-Shared/base/perl/install/bin/perl)
==15500==    by 0x441EE5: perl_run (in /media/paul/Linux-Shared/base/perl/install/bin/perl)
==15500==    by 0x41F9F4: main (in /media/paul/Linux-Shared/base/perl/install/bin/perl)

@pmqs pmqs transferred this issue from pmqs/Archive-Zip-SimpleZip Nov 7, 2019
@pmqs
Copy link
Owner Author

pmqs commented Nov 7, 2019

The libarchive library includes a change that covers the same leak. See libarchive/libarchive@8c0c4fd

The change in libarchive involves explicitly freeing the options data structure

	ret = lzma_raw_decoder(&(state->stream), filters);
#if LZMA_VERSION < 50010000
	free(filters[0].options);
#endif

@pmqs
Copy link
Owner Author

pmqs commented Nov 9, 2019

Issue reported upstream to the liblzma library https://sourceforge.net/p/lzmautils/discussion/708858/thread/53c6321fc4/

@pmqs
Copy link
Owner Author

pmqs commented Nov 9, 2019

Fixed by 05c0eac and b020045

Fixed included in 2.090

@pmqs pmqs closed this as completed Nov 9, 2019
clrpackages pushed a commit to clearlinux-pkgs/perl-Compress-Raw-Lzma that referenced this issue Nov 12, 2019
  2.090 9 November 2019

      * Memory leak in raw_decoder
        Issue pmqs/Compress-Raw-Lzma#1
        05c0eac3ab1edd05e5bc945463af004dcbc88c00
        b020045e17a7ab7338c010f5100ec63e8e8e9040
pmqs added a commit that referenced this issue Nov 23, 2019
pmqs added a commit that referenced this issue Nov 23, 2019
clrpackages pushed a commit to clearlinux-pkgs/perl-Compress-Raw-Lzma that referenced this issue Nov 27, 2019
  2.091 23 November 2019

      * More updates for memory leak in raw_decoder
        Issue pmqs/Compress-Raw-Lzma#1
        08e80080b0d94e17eb1e9ceed589b145cdaf8495
        ac9b6e5c9c6966a40d1a6caf2f2c6dc021ed50d9

      * Silence compiler warning
        pmqs/Compress-Raw-Lzma#1
        c496f8716b3651cab2753cf90a3aa47a7ce0a339
@pmqs pmqs self-assigned this Sep 17, 2020
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