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 442860 - Segmentation fault in glade_id_allocator_release()
Segmentation fault in glade_id_allocator_release()
Status: RESOLVED FIXED
Product: glade
Classification: Applications
Component: general
3.2.x
Other All
: Normal critical
: ---
Assigned To: Glade 3 Maintainers
Glade 3 Maintainers
: 412047 438974 462769 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2007-06-01 10:34 UTC by Maarten Bressers
Modified: 2008-03-11 00:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
sample.glade (12.26 KB, text/plain)
2007-06-01 10:35 UTC, Maarten Bressers
Details

Description Maarten Bressers 2007-06-01 10:34:22 UTC
Steps to reproduce:
Steps to Reproduce:
1.open the sample.glade file (see attachment)
2.doubleclick "window" in Inspector
3.click on the "." (period) button to select it
4.change the name of this button to "num_00" (Properties, tab General)
5.select "table" in Inspector
6.change number of rows to 5 (new row appears below others)
7.right-click on the "0" (zero) button, select "copy"
8.right-click on empty space below "0" button, select paste
9.right-click "." button, select "cut"
Segmentation fault

Stack trace:
Program received signal SIGSEGV, Segmentation fault.
0x00002b90ca4ad5bf in glade_id_allocator_release (allocator=0x111f7c0,
id=4294967295) at glade-id-allocator.c:142
142             allocator->data[id >> 5] |= 1 << (id & 31);
(gdb) bt
  • #0 glade_id_allocator_release
    at glade-id-allocator.c line 142
  • #1 glade_project_release_widget_name
    at glade-project.c line 938
  • #2 glade_project_remove_object
    at glade-project.c line 992
  • #3 glade_command_remove_execute
    at glade-command.c line 1253
  • #4 glade_command_add_remove_execute
    at glade-command.c line 1274
  • #5 glade_command_remove
    at glade-command.c line 1073
  • #6 glade_command_cut
    at glade-command.c line 1590
  • #7 glade_app_command_cut
    at glade-app.c line 1171
  • #8 glade_popup_cut_cb
    at glade-popup.c line 65
  • #9 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #10 ??
    from /usr/lib/libgobject-2.0.so.0
  • #11 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #12 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #13 gtk_widget_activate
    from /usr/lib/libgtk-x11-2.0.so.0
  • #14 gtk_menu_shell_activate_item
    from /usr/lib/libgtk-x11-2.0.so.0
  • #15 ??
    from /usr/lib/libgtk-x11-2.0.so.0
  • #16 ??
    from /usr/lib/libgtk-x11-2.0.so.0
  • #17 g_closure_invoke
    from /usr/lib/libgobject-2.0.so.0
  • #18 ??
    from /usr/lib/libgobject-2.0.so.0
  • #19 g_signal_emit_valist
    from /usr/lib/libgobject-2.0.so.0
  • #20 g_signal_emit
    from /usr/lib/libgobject-2.0.so.0
  • #21 ??
    from /usr/lib/libgtk-x11-2.0.so.0
  • #22 gtk_propagate_event
    from /usr/lib/libgtk-x11-2.0.so.0
  • #23 gtk_main_do_event
    from /usr/lib/libgtk-x11-2.0.so.0
  • #24 ??
    from /usr/lib/libgdk-x11-2.0.so.0
  • #25 g_main_context_dispatch
    from /usr/lib/libglib-2.0.so.0
  • #26 ??
    from /usr/lib/libglib-2.0.so.0
  • #27 g_main_loop_run
    from /usr/lib/libglib-2.0.so.0
  • #28 gtk_main
    from /usr/lib/libgtk-x11-2.0.so.0
  • #29 main
    at main.c line 177


Other information:
The steps to reproduce are very specific, I know. Naming the "." button
something else, like "num_99" or "bla" doesn't cause a segfault. Also,
cut/pasting the "." without first copy/pasting another button doesn't segfault.
Copy/pasting the "1" button into the empty space below the "0", followed by the
cut/paste of the ".", does segfault, but copy/pasting the "=" button into the
empty space below the "0", followed by the cut/paste of the ".", does not
segfault.

If there's any more info I could provide, please let me know.
Comment 1 Maarten Bressers 2007-06-01 10:35:58 UTC
Created attachment 89172 [details]
sample.glade

use this file to reproduce the steps outlined in the bug report
Comment 2 Tristan Van Berkom 2007-06-01 17:11:11 UTC
Thankyou so much, we've been noticing crashes in the id allocator
(and I'm aware of some rework that needed to be done) but we havent
had anything specifically reproducable till now... I'm going to take
a closer look, thanks again.
Comment 3 Vincent Geddes 2007-06-16 22:42:01 UTC
*** Bug 412047 has been marked as a duplicate of this bug. ***
Comment 4 Vincent Geddes 2007-06-16 22:42:19 UTC
*** Bug 438974 has been marked as a duplicate of this bug. ***
Comment 5 Vincent Geddes 2007-06-24 01:27:11 UTC
This crash occurs due to two factors...

Firstly, consider this debug output (following repro instructions):
./glade3
DEBUG: (glade_id_allocator_allocate) allocator: 0x12e5c90; id: 1;
DEBUG: (glade_id_allocator_allocate) allocator: 0x12e5c90; id: 2;
DEBUG: (glade_id_allocator_allocate) allocator: 0x12e5c90; id: 3;
DEBUG: (glade_id_allocator_allocate) allocator: 0x12e5c90; id: 4;
DEBUG: (glade_id_allocator_allocate) allocator: 0x12e5c90; id: 5;
DEBUG: (glade_id_allocator_allocate) allocator: 0x12e5c90; id: 6;
DEBUG: (glade_id_allocator_allocate) allocator: 0x12e5c90; id: 7;
DEBUG: (glade_id_allocator_allocate) allocator: 0x12e5c90; id: 8;
DEBUG: (glade_id_allocator_allocate) allocator: 0x12e5c90; id: 9;
DEBUG: (glade_id_allocator_allocate) allocator: 0x12e5c90; id: 10;
DEBUG: (glade_id_allocator_allocate) allocator: 0x12e5c90; id: 11;
DEBUG: (glade_project_release_widget_name) widget-name: num_00;
DEBUG: (glade_id_allocator_release) allocator: 0x12e5c90; id: 0;
Segmentation fault (core dumped)


Factor 1:
if you pass `0' as the second parameter to  
`glade_id_allocator_release (GladeIDAllocator* allocator, guint id)', you will get a segmentation fault.

In glade_id_allocator_release():
Since we have that `id' is unsigned and id equals 0, the op `id--' results in a large number such as `3252352235'. This is promptly followed by a segmentation fault because of the out-of-bounds array access `data[id>>5]'.

The correct solution is to ensure that glade_id_allocator_release() sticks to it's contract as defined by the parameter types it declares as acceptable. It must accept `0' as a parameter.


Factor 2:

From observing the debug output, notice that we attempt to release the id `0' without having allocated it first. This is invalid. It's also wrong that we are dealing with an `0' id in the first place. I believe it's the case that id must be greater than 0.
 
Comment 6 Tristan Van Berkom 2007-08-02 13:51:38 UTC
*** Bug 462769 has been marked as a duplicate of this bug. ***
Comment 7 Tristan Van Berkom 2008-03-11 00:04:28 UTC
Ok this bug is fixed in svn, overall widget name policing should
be better all around.