On Tue, 2011-07-19 at 19:56 -0400, David Malcolm wrote:
On Tue, 2011-07-19 at 15:42 +0200, Denys Duchier wrote:
David Malcolm dmalcolm@redhat.com writes:
To get a backtrace from the plugin, you need to locate the invocation line for the gcc harness, then add "-v" to the options to see the invocation of the c compiler ("cc1"). You should then be able to run it under gdb like this:
$ gdb --args FULL ARGS OF cc1 INVOCATION (gdb) run
Here is what I get (does it help?):
[snip]
Program received signal SIGSEGV, Segmentation fault. 0x0848457a in lookup_attribute () (gdb) bt #0 0x0848457a in lookup_attribute () #1 0x08489141 in build_pointer_type_for_mode () #2 0x08489273 in build_pointer_type () #3 0xb79ed91f in gcc_TypeDecl_get_pointer (self=0xb7537670, closure=0x0) at autogenerated-tree.c:3963 #4 0xb787203d in ?? () from /usr/lib/libpython2.7.so.1.0 (gdb) f 3 #3 0xb79ed91f in gcc_TypeDecl_get_pointer (self=0xb7537670, closure=0x0) at autogenerated-tree.c:3963 3963 return gcc_python_make_wrapper_tree(build_pointer_type(self->t)); (gdb) list 3958 }; 3959 3960 static PyObject * 3961 gcc_TypeDecl_get_pointer(PyGccTree *self, void *closure) 3962 { 3963 return gcc_python_make_wrapper_tree(build_pointer_type(self->t)); 3964 } 3965 3966 static PyGetSetDef gcc_TypeDecl_getset_table[] = { 3967 {"pointer",
I managed to reproduce this on an i686 box, and I have fixed it; all selftests now pass on the i686 box I'm working on (all with gcc 4.6.0, fwiw)
If you "git pull", does the revised code work for you now?
It turned out to be a much deeper problem than I expected: gcc_TypeDecl_get_pointer() was calling:
gcc_python_make_wrapper_tree(build_pointer_type(self->t));
where (tree)(self->t) had TREE_CODE() == TYPE_DECL, and thus tree_code_type[TYPE_DECL] is tcc_declaration.
build_pointer_type() assumes the tree passed in is of tcc_type.
So my code was violating GCC's internal type system. (FWIW, I've been using an optimized build of GCC, in which the type checking for trees is disabled; it looks like I ought to do my development against a debug build with the tree type checking turned on).
Somehow this was surviving on x86_64, with gcc.TypeDecl.pointer was returning a pointer to a thing that was being treated as a type; somehow all usage of the resulting thing managed to work, despite violating type constraints.
On i686 it was less "fortunate", and segfaulted almost immediately, during the lookup of the "may_alias" attribute (on the type_decl-being-treated-as-a-type).
The bug should now be fixed, as of commit 1d42de33a0ce9225d98fa35b1fa44ad57c9305a3, and I committed some other test suite fixes for i686 as 99b36c7501b555acc0491928f4a5f9a6b141265a
Thanks for reporting this bug! Dave