[Poppler-bugs] [Bug 77790] New: get_text_layout introspection mismatch

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Tue Apr 22 20:35:51 PDT 2014


https://bugs.freedesktop.org/show_bug.cgi?id=77790

          Priority: medium
            Bug ID: 77790
          Assignee: poppler-bugs at lists.freedesktop.org
           Summary: get_text_layout introspection mismatch
          Severity: normal
    Classification: Unclassified
                OS: All
          Reporter: marcus.brinkmann at ruhr-uni-bochum.de
          Hardware: Other
            Status: NEW
           Version: unspecified
         Component: glib frontend
           Product: poppler

Hi,

$ cat girtest.js
const pop = imports.gi.Poppler;
const doc = pop.Document.new_from_file("file:///path/to/test.pdf", '')
const page=doc.get_page(0)
log(page.get_text_layout())

$ gjs girtest.js
Segmentation fault (core dumped)

Backtrace follows below.  What actually happens is that gir expects
get_text_layout to return an array of PopplerRectangle* (an array of pointers
to allocated PopplerRectangle objects), while it actually returns an array of
PopplerRectangle (one continuous malloc region with all rectangles
side-by-side).

The confusion occurs naturally in C, as the type "Foo*" can be a pointer to a
single Foo object, or an array of Foo objects.

>From a cursory glance at gir, it seems the actual data layout currently
implemented is not supported by gir, and that the PopplerRectangles have to be
allocated separately.  This would be an API change.

If one tries to trick gir and change the header file to a PopplerRectangle*
(instead of the **), one gets:

$ gjs girtest.js

(gjs:20441): Gjs-WARNING **: JS ERROR: Error: Unsupported type array for (out
caller-allocates)
@girtest.js:4

JS_EvaluateScript() failed

Here is the backtrace:

(gdb) bt
#0  __memcpy_sse2_unaligned () at
../sysdeps/x86_64/multiarch/memcpy-sse2-unaligned.S:37
#1  0x00007ffff69393a7 in g_slice_copy (mem_size=32,
mem_block=0x40519322d0e56042) at gslice.c:1056
#2  0x00007ffff6c166d3 in g_boxed_copy (boxed_type=8036912,
src_boxed=0x40519322d0e56042) at gboxed.c:352
#3  0x00007ffff7d9cf54 in gjs_boxed_from_c_struct (context=0x636ff0,
info=<optimized out>, gboxed=0x40519322d0e56042, flags=<optimized out>) at
gi/boxed.cpp:1236
#4  0x00007ffff7d99d43 in gjs_value_from_g_argument
(context=context at entry=0x636ff0, value_p=value_p at entry=0x7fffffffc500,
type_info=type_info at entry=0x72aa30,
    arg=arg at entry=0x7fffffffc510, copy_structs=copy_structs at entry=1) at
gi/arg.cpp:2642
#5  0x00007ffff7d9a1fb in gjs_array_from_carray_internal
(context=context at entry=0x636ff0, value_p=value_p at entry=0x7fffffffc5c8,
param_info=param_info at entry=0x72aa30,
    length=length at entry=483, array=<optimized out>) at gi/arg.cpp:2143
#6  0x00007ffff7d9a695 in gjs_value_from_explicit_array (context=0x636ff0,
value_p=0x7fffffffc5c8, type_info=<optimized out>, arg=0x7fffffffc618,
length=483)
    at gi/arg.cpp:2195
#7  0x00007ffff7d9fe03 in gjs_invoke_c_function
(context=context at entry=0x636ff0, function=function at entry=0x6d0de0,
obj=obj at entry=0x7fffee735cd0, js_argc=js_argc at entry=0,
    js_argv=js_argv at entry=0x68e508, js_rval=js_rval at entry=0x7fffffffc970,
r_value=r_value at entry=0x0) at gi/function.cpp:1140

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/poppler-bugs/attachments/20140423/dc208953/attachment.html>


More information about the Poppler-bugs mailing list