glib2.26: bus error in gtype.c:4073 type_check_is_value_type_U()



Greetings, 

I have written a few applications that use GTK and I am pretty happy
with it so far and appreciate all the work you are doing. I have been
contributing to the TinyCC compiler http://repo.or.cz/w/tinycc.git
(public mob branch!) while I learn C and GTK+. I also started messing
around writing a fun, free GPL tool that adds missing brackets and
semicolons to C code though it's not a language parser, so it can't
really handle all cases... http://freshmeat.net/projects/anchor

I am writing the list because I ran into an odd struct alignment problem
with glib2.26 today compiling with TinyCC on x86_64 and structure
packing is not my specialty. If you have a good reference that would
help me debug this I would be grateful.

If I compile this application with gcc or the i386 version of tcc it
works, but if I do the compilation with tcc (created by running
configure [options] &&make on x86_64) glib2.26 generates a bus error. I
tried what I think are the usual workarounds for this, but I doubt
TinyCC understands things like -funaligned-struct-hack ;). Although it
is possible it is a TinyCC bug, I thought I would share this because
this section of glib2 code came up in searches as being problematic with
other applications in the past and perhaps it would benefit from better
error detection.

The compile command used with TinyCC:

$ tcc -g gtktest.c -o gtktest $(pkg-config --cflags --libs gtk+-2.0)

Debugging with gdb.

$ gdb -tui ./gtktest

(click the mouse on the image to generate the error)

  gtype.c----------------------------------------------------
 │4065    static inline gboolean                             |
 │4066    type_check_is_value_type_U (GType type)            |
 │4067    {                                                  |
 │4068      GTypeFlags tflags = G_TYPE_FLAG_VALUE_ABSTRACT;  |
 │4069      TypeNode *node;                                  |
 │4070                                                       |
 │4071      /* common path speed up */                       |
 │4072      node = lookup_type_node_I (type);                |
>│4073      if (node && node->mutatable_check_cache)         |
 │4074        return TRUE;                                   |

 Program	received signal	SIGBUS,	Bus error.
0x00000039a3033ab0 in type_check_is_value_type_U (value=0x80a8188,
type=20) at gtype.c:4073

(gdb) p	node
$1 = (TypeNode *) 0x4039000000000000

^^^If you will note here, node has a very odd value when it crashes from
clicking the mouse on it. It is normally something like (TypeNode *)
0x80529d8 and the program does run fine until the mouse is clicked.

test program attached.

Happy Turkey Day! :D
-henry

Attachment: flippy.zip
Description: Zip archive



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