This queue is for tickets about the PDF-API2 CPAN distribution.

Report information
The Basics

Nobody in particular
sfetisov [...]

(no value)
Broken in:
(no value)
Fixed in:

CC: <>
Subject: stack overflow in the PDF::API2
Date: Tue, 18 Nov 2008 16:23:37 -0800
To: <>
From: "Sergei Fetisov" <>

Dear Alfred,


We are using the PDF::API2 package with ActiveState Perl 5.8 under Windows XP/2003.

This is an extremely helpful package. Unfortunately, recently I found an issue.

There is a non optimized regular expression at PDF::API2::Basic::PDF::File package, line 648:


$str =~ /^((?:[^\\()]|\\[^()])*)(.*)/so;


Perl5.8 has a recursion code in the regexp engine.

The pattern could contain of a huge number of matches and invoke a deep recursion.

So the regular expression engine is running out of stack space and it causes segmentation fault.

For example, it happens when PDF file contains of the really big metadata (e.g. 30000 characters in the Keywords field).


I think the next regular expression could be used instead and it should resolve the issue:

$str =~ /^(\\?[^\\()]+)(.*)/so;


We are going to update the Perl version up to 5.10 in the future and it has to fix the problem too.

In the meanwhile, we would like to let you know about the issue and it will be great if you have a chance to fix it.


Thank you,


Sergei Fetisov
Senior Member of Technical Staff
Stratify, an Iron Mountain Company
501 Ellis Street
Mountain View, CA 94043
Phone: 650-963-3989
Fax: 650-988-2159


The information contained in this email message and its attachments is intended only for the private and confidential use of the recipient(s) named above, unless the sender expressly agrees otherwise. Transmission of email over the Internet is not a secure communications medium. If you are requesting or have requested the transmittal of personal data, as defined in applicable privacy laws by means of email or in an attachment to email you must select a more secure alternate means of transmittal that supports your obligations to protect such personal data. If the reader of this message is not the intended recipient and/or you have received this email in error, you must take no action based on the information in this email and you are hereby notified that any dissemination, misuse, copying, or disclosure of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by email and delete the original message.


I've rewritten this section of the code in changeset 9c94b7cf1700 (see the BitBucket repository) in such a way that this issue should be resolved. Since there aren't any tests exercising this code in a significant way, I'll try this version out at my work for a while before releasing it, to see if any new errors pop up.

This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with to