Re: G::O::I based bindings and problem passing char array ref



Of course, forgot to attach. Here is dump.

On Fri, 3 Jun 2016 14:44:58 -0500
Jeremy Volkening <jdv base2bio com> wrote:

If I futz with the .gir and change the new_from_data() "data"
parameter type to a guint8 array (and then pass it a character
array ref) I can load and read the page number from most of the
files that were previously throwing errors. Then the script
segfaults almost every time...

Can you provide a backtrace and or Valgrind output?

# gdb --args perl program.pl
(gdb) run
...
(gdb) bt

# valgrind perl program.pl

Attached is the valgrind dump from my test script. This is after
changing the section of the .gir for poppler_document_new_from_data()

FROM:

<parameter name="data" transfer-ownership="none">
    <doc xml:space="preserve">the pdf data contained in a char
array</doc> <type name="utf8" c:type="char*"/>
</parameter>

TO:

<parameter name="data" transfer-ownership="none">
    <doc xml:space="preserve">the pdf data contained in a char
array</doc> <array length="1" zero-terminated="0" c:type="gchar*">
        <type name="guint8"/>
    </array>
</parameter>


and then passing an array ref. Oddly enough, if I run the test script
through valgrind everything works (i.e. it prints the expected
metadata and renders the first page as PNG). This is true for any
PDF. If I run the same command without valgrind it segfaults.
Apparently valgrind helps it survive errors. This proves in any case
that the PDF is being read.

I have also observed that, with the unmodified libs, any PDF that
'file' reports as 'utf-8' or 'unknown-8bit' works, but anything
reported as 'binary' or 'iso-8859-1' (most files) fails.

Jeremy

Attachment: poppler.valgrind.dump.bz2
Description: application/bzip



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]