Skip to content

PDF::API2->from_string causes for action "page1-to-thumbnail" an OOM (memory-leak, loop) #78

@neffets

Description

@neffets

We have normal pdf created with "Acrobat PDFMaker for Word". It has only 6 pages.

We try to generate a Thumbnail from the PDF per PDF::API2

$file = '2024_Q1_-digitale-Veranstaltungen_de.pdf';
my $data = do {
    local $/ = undef;
    open my $fh, "<", $file or die "could not open $file: $!";
    <$fh>;
};

$pdf = PDF::API2->from_string($data);
# never gets here

my $sp_pdf = new PDF::API2;
eval {
    $sp_pdf->import_page($pdf,1,0);
};
if ($@) {
    warn $@;
}
my $image = Image::Magick->new;
$error = $image->BlobToImage($sp_pdf->stringify);

It hangs on line 1 (first from_string()) forever, increasing the use resident-memory over time (using 1GB per 300 seconds more)
2024_Q1_-digitale-Veranstaltungen_de.pdf

Workaround is to encapsulate the "from_string" method with an POSIX::sigaction and alarm(10).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions