After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 157998 - [incident] using either -O2 or -g exclusively seemingly fixes segfaults.
[incident] using either -O2 or -g exclusively seemingly fixes segfaults.
Status: RESOLVED OBSOLETE
Product: glade
Classification: Applications
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Glade 3 Maintainers
Glade 3 Maintainers
Depends on:
Blocks:
 
 
Reported: 2004-11-11 20:42 UTC by Tristan Van Berkom
Modified: 2010-12-16 18:57 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Tristan Van Berkom 2004-11-11 20:42:55 UTC
I'm sure this cant be standard behaviour, and it definitly
breaks my build (gcc 3.2.2)

These to compiler flags leave me in some situations, wierd link problems.

the one I just bumped into:
    a.o calls function "set (a, b, c, d)" in object b.o
    b.o function "set" gets called with arguments "(a, c, c, d)"

This should be fixed 

Currently workaround is to :

$ CFLAGS="-g" ./configure ... (usual args...)
Comment 1 Nickolay V. Shmyrev 2006-01-16 06:55:06 UTC
It's default automake behaviour. You can override it in various ways, for example, by passing CFLAGS in command line.

The problem about arguments you've described is a sequence of optimization, not the error in compiler. It just puts some params on register, making it hard to retrieve their actual values.
Comment 2 Tristan Van Berkom 2006-01-16 14:56:54 UTC
Nickolay,
    Maybe you have misunderstood; this is a serious issue, the fact that
one object file's function gets called with different arguments than
the arguments that we're provided from another object file always results
in unexpected behaviour (and its damn hard to nail when your running
after a segfault but you're really experiencing a compiler mis-hap).

This means that when compiling glade; depending on your binutils/gcc,
toolchain & environment; if you dont set CFLAGS by hand at configure
time you might get segfaults and unexpected behaviour; that is
definitly a bug and is unacceptable.

Is there anyway you know that I can override this behaviour at a
higher level ? can I do this in a safe & portable way from
the autogen.sh or configure.in file so that compiler flags are 
fixed also in a resulting package of `make dist' ?
Comment 3 Nickolay V. Shmyrev 2006-01-16 18:11:24 UTC
Sorry for misunderstanding Tristan.

Do I understand correctly that you are calling functions with different set of parametrs in glade code? In that case it's nothing about compiler optimization and you certainly should not force -O0. Instead you should fix the code where it happens. Can you show the place in glade sources about that?
Comment 4 Tristan Van Berkom 2006-01-16 18:43:55 UTC
I wish that I could remember exactly where it has occured, I was using
gcc 2.95.3 last time I saw this bug (and have been compiling with only -g
since then; assuming that comiling with -O2 without -g would work fine
too).

I'm not sure what exactly you mean by "different set of parametrs" so
let me illustrate the problem that occurred:

    o Having some strange segfaults... trapping in gdb.
    o Segfaulting inside glade_property_class_somefunction () that
      was called from glade_widget_somefunction ().
    o In gdb; either the argument values were "not available" or were
      noticably skewed.
    o Didn't trust gdb; went on to print all the arguments in
      glade_property_class_somefunction() and all the arguments
      in glade_widget_somefunction() before invoking
      glade_property_class_somefunction().

      After printing with g_print(); I was assured that glade-widget.c 
      was indeed providing the correct arguments, but glade-property-class.c
      was recieving them skewed (like recieving twice the first arg
      and never the second).

Do you think its possible that I was using some unsupported form
of C code to invoke the function from another object ?
(from memory; the all the arguments were pointer to GObject derivatives
or to GValue or to const GValue)

Note also that I've ran into the same problem (also using gcc 2.95.3)
in another large project in the past (and noticed that I was optimizing
and adding profiler information at the same time); thats why I was so 
quick to write it off as a "problem with my gcc options".

My fear now is that if I close this bug, some people with older
compilers will still get this bug, or will only get this bug after
modifying some code.

Can anyone speak for the "safeness" of combining the "-O2" & "-g"
compiler flags ?
Comment 5 Nickolay V. Shmyrev 2006-01-16 20:58:13 UTC
Sorry once again, please do whatever you want. 

About actual problem, it may be caused by stack memory corruption, not linking/compiling problems. In that case you'll can get arbitrary arguments. Of course, they will depend on -g and -O2, but this dependance is a side-effect, not a cause. That is why I was confused by this bug title and description.

I may be wrong, but almost all Fedora is built with -g -O2 since it's default automake settings. I wonder if they had problems with it.
Comment 6 Tristan Van Berkom 2006-01-17 00:39:19 UTC
I see your point,
   it could definitly be some kind of stack corruption that
was already resident but only caused segfaults when compiling
with `-O2 -g'.

Unfortunately this goes so far back that I'm not even going to
try to reproduce the crashes; so I think the practicle thing to
do is leave this open as an incedent purly for future reference
(if this happens again I think it will help).

It still bothers me that I've seen this happen in another project
where compiling with either -O2 *or* -g fixed the problem, also with
the same compiler... it still also strikes me as odd to ask the
compiler to optimize the code & add profiling information (which
"should work", just sounds like asking for trouble).

/me lives with his unsolved mysteries
Comment 7 Tristan Van Berkom 2006-07-13 19:51:20 UTC
well its happened again.

After Juan commits shortly... it will be unsafe to combine -O2 and -g
while building glade3 on my host (gcc-4.0.2/Linux-2.6.12-9).

The problem is that glade-gtk.c calls glade_base_editor_new()
(from glade-base-editor.c) and everything compiles fine...
then when it comes to calling the actual function, I get a wild
stack pointer instead.

Any ideas ?
Comment 8 Daniel Kasak 2006-07-14 05:33:30 UTC
Same here. I'm using gcc-4.1.1. I compiled glade-3 from CVS with the default CFLAGS ( which is -O2 I believe ). When I cut something and paste it into a GtkHPaned, I *always* get a segfault. If I recompile glade-3 with the CFLAGS "-g" I can cut / paste into GtkHPaned widgets to my heart's content :)

Backtrace was generated from '/usr/local/bin/glade-3'

Using host libthread_db library "/lib/libthread_db.so.1".
`system-supplied DSO at 0xffffe000' has disappeared; keeping its symbols.
[Thread debugging using libthread_db enabled]
[New Thread -1219250512 (LWP 17399)]
0xffffe410 in __kernel_vsyscall ()

Thread 1 (Thread -1219250512 (LWP 17399))

  • #0 __kernel_vsyscall
  • #1 waitpid
    from /lib/libc.so.6
  • #2 gnome_gtk_module_info_get
    from /usr/lib/libgnomeui-2.so.0
  • #3 <signal handler called>
  • #4 gtk_paned_add1
    from /usr/lib/libgtk-x11-2.0.so.0
  • #5 g_cclosure_marshal_VOID__OBJECT
    from /usr/lib/libgobject-2.0.so.0
  • #6 g_value_set_boxed
    from /usr/lib/libgobject-2.0.so.0
  • #7 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #8 g_signal_chain_from_overridden
    from /usr/lib/libgobject-2.0.so.0
  • #9 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #10 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #11 gtk_container_set_focus_child
    from /usr/lib/libgtk-x11-2.0.so.0
  • #12 gtk_widget_unparent
    from /usr/lib/libgtk-x11-2.0.so.0
  • #13 gtk_paned_add1
    from /usr/lib/libgtk-x11-2.0.so.0
  • #14 g_cclosure_marshal_VOID__OBJECT
    from /usr/lib/libgobject-2.0.so.0
  • #15 g_value_set_boxed
    from /usr/lib/libgobject-2.0.so.0
  • #16 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #17 g_signal_chain_from_overridden
    from /usr/lib/libgobject-2.0.so.0
  • #18 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #19 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #20 gtk_container_remove
    from /usr/lib/libgtk-x11-2.0.so.0
  • #21 glade_gtk_container_replace_child
    at glade-gtk.c line 309
  • #22 glade_widget_class_container_replace_child
    at glade-widget-class.c line 1554
  • #23 glade_widget_replace_child_impl
    at glade-widget.c line 147
  • #24 glade_widget_replace
    at glade-widget.c line 3285
  • #25 glade_command_paste_execute
    at glade-command.c line 1238
  • #26 glade_command_cut_copy_paste_common
    at glade-command.c line 1627
  • #27 glade_app_command_paste
    at glade-app.c line 1170
  • #28 glade_popup_placeholder_paste_cb
    at glade-popup.c line 136
  • #29 g_cclosure_marshal_VOID__VOID
    from /usr/lib/libgobject-2.0.so.0
  • #30 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #31 g_signal_chain_from_overridden
    from /usr/lib/libgobject-2.0.so.0
  • #32 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #33 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #34 gtk_widget_activate
    from /usr/lib/libgtk-x11-2.0.so.0
  • #35 gtk_menu_shell_activate_item
    from /usr/lib/libgtk-x11-2.0.so.0
  • #36 gtk_menu_shell_append
    from /usr/lib/libgtk-x11-2.0.so.0
  • #37 gtk_menu_attach
    from /usr/lib/libgtk-x11-2.0.so.0
  • #38 gtk_marshal_BOOLEAN__VOID
    from /usr/lib/libgtk-x11-2.0.so.0
  • #39 g_value_set_boxed
    from /usr/lib/libgobject-2.0.so.0
  • #40 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #41 g_signal_chain_from_overridden
    from /usr/lib/libgobject-2.0.so.0
  • #42 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #43 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #44 gtk_widget_get_default_style
    from /usr/lib/libgtk-x11-2.0.so.0
  • #45 gtk_propagate_event
    from /usr/lib/libgtk-x11-2.0.so.0
  • #46 gtk_main_do_event
    from /usr/lib/libgtk-x11-2.0.so.0
  • #47 gdk_add_client_message_filter
    from /usr/lib/libgdk-x11-2.0.so.0
  • #48 g_main_context_dispatch
    from /usr/lib/libglib-2.0.so.0
  • #49 g_main_context_check
    from /usr/lib/libglib-2.0.so.0
  • #50 g_main_loop_run
    from /usr/lib/libglib-2.0.so.0
  • #51 gtk_main
    from /usr/lib/libgtk-x11-2.0.so.0
  • #52 main
    at main.c line 175
  • #0 __kernel_vsyscall