[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-smalltalk] Re: GNU Smalltalk crashes when calling xcb_create_windo
From: |
Paolo Bonzini |
Subject: |
[Help-smalltalk] Re: GNU Smalltalk crashes when calling xcb_create_window via cCall |
Date: |
Wed, 30 Sep 2009 14:59:42 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Lightning/1.0pre Thunderbird/3.0b3 |
On 09/29/2009 09:14 PM, Dmitry Matveev wrote:
Hello,
New gdb log is attacted.
GNU Smalltalk is build from git (2-3 days ago).
Aha, got it.
I tried using gdb to print the stack in xcb_create_window from both the
failing and the succeeding call.
Here is the failing call to xcb_create_window. We have first the next
stack frame, then the return address, then the arguments (this is
32-bit, which does not pass arguments in registers):
(gdb) p/x *(uint32_t **) address@hidden
$6 = {0xffffb2a8, 0x427c27, 0x80c92b8, 0x0, 0x4400000, 0x10b, 0x0, 0x0,
0x96, 0x96, 0xa, 0x1, 0x21, 0x0, 0x0}
Here is the succeeding call to gst_xcb_create_window:
(gdb) p/x *(uint32_t **)address@hidden
$4 = {0xffffb298, 0x37bc27, 0x80c92b8, 0x0, 0x4600000, 0x10b, 0x0, 0x0,
0x96, 0x96, 0xa, 0x1, 0x21, 0x0, 0x0, 0xffffb2d8, 0x37ba3e, 0x37bab0,
0xffffb2c4, 0x34}
This looks the same---correct, since the cCall pragma was the same.
Now here is the succeeding call to xcb_create_window
(gdb) down
#0 0x001946a5 in xcb_create_window () from /usr/lib/libxcb.so.1
(gdb) p/x *(uint32_t **)address@hidden
$5 = {0xffffb25c, 0x110618, 0xffffb224, 0x80c92b8, 0x0, 0x4600000,
0x10b, 0x0, 0x0, 0x96, 0x96, 0xa, 0x1, 0x21, 0x0, 0x0, 0x8074540,
0xffffb2c0, 0xffffb438, 0xe3c3eb22}
Notice the "0xffffb224" after the return address? That is the place
where the callee can store the return value, which is not a "void" but
an "xcb_void_cookie_t" -- which is a struct.
So, you have to wrap all the function calls of XCB that are asynchronous
(like xcb_create_window and xcb_map_window). However, note that big
parts of libxcb, in particular these very functions, are automatically
generated from XML, for example:
<request name="CreateWindow" opcode="1">
<field type="CARD8" name="depth" />
<field type="WINDOW" name="wid" />
<field type="WINDOW" name="parent" />
<field type="INT16" name="x" />
<field type="INT16" name="y" />
<field type="CARD16" name="width" />
<field type="CARD16" name="height" />
<field type="CARD16" name="border_width" />
<field type="CARD16" name="class" />
<field type="VISUALID" name="visual" />
<valueparam value-mask-type="CARD32"
value-mask-name="value_mask"
value-list-name="value_list" />
</request>
See
http://www.google.com/codesearch/p?hl=en&sa=N&cd=1&ct=rc#9m0-3TEx8PU/trunk/vcf/src/thirdparty/X11/xcb/proto/src/xproto.xml&q=file:xproto.xml
Unfortunately I could not find the generator, also because
cgit.freedesktop.org is down. But if there is one, generating the XCB
request functions (i.e. not the whole bindings, only the requests) from
GNU Smalltalk may be a viable path.
BTW, your code has a small memory leak. You can say
iter := XcbScreenIterator gcNew.
instead of "new".
Paolo