"Can't upgrade that kind of scalar" crash from PDF::API2::Basic::PDF::Objind
"alankila2" <alankila2-FFYn/[email protected]> Mon, 11 Aug 2008 12:38:51 -0000
| Newsgroups | gmane.comp.lang.perl.modules.pdfapi2 |
|---|---|
| Message-ID | <[email protected]> |
The faulty line appears to be in copy() method:
if (UNIVERSAL::can($self->{$k}, "is_obj") && !$self->{$k}->is_obj($pdf))
It seems that when passing the ' stream' property to UNIVERSAL::can()
sometimes causes Perl to crash with "Can't upgrade that kind of
scalar" message. I have not yet satisfactorily narrowed down the
conditions for this error, but I can still propose a workaround that
corrected the bug for us:
if (ref($self->{$k}) && UNIVERSAL::can($self->{$k}, "is_obj") &&
!$self->{$k}->is_obj($pdf))
The error message "Can't upgrade that kind of scalar" arises most
commonly when doing something like this:
substr($_, 0) = *a;
or
tie my %hash, "Tie::IxHash";
$hash{a} = *b;
This is to say, typeglobs can not be assigned to lvalues, and you
can't use them with tied objects.
It is not clear to me what is wrong with the specific situation
concerning the case we are seeing here. So far I know the following:
- the crash originates in $pdf1->importPageIntoForm($pdf2, $pagenum);
- $pdf2 is opened via openScalar, $pdf1 is a PDF::API2->new() object;
- the bug only occurs when PDF::API2 is used by our custom web
framework, it does not occur on the commandline program doing the same;
- the bug occurs only 1 specific PDF file;
- of the 6 pages in the PDF, the page which crashes is 4th and it is
different from the other pages in that it is smaller than the other pages.