glabels crashed with SIGFPE in g_type_create_instance()

Bug #551958 reported by James Kittsmiller
120
This bug affects 21 people
Affects Status Importance Assigned to Milestone
glabels (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

Binary package hint: glabels

open program
Select label
try to add a txt or image and program crashes..

ProblemType: Crash
DistroRelease: Ubuntu 10.04
Package: glabels 2.2.7-2
ProcVersionSignature: Ubuntu 2.6.32-18.27-generic 2.6.32.10+drm33.1
Uname: Linux 2.6.32-18-generic i686
NonfreeKernelModules: nvidia
Architecture: i386
CrashCounter: 1
Date: Tue Mar 30 14:39:31 2010
ExecutablePath: /usr/bin/glabels
InstallationMedia: Ubuntu 10.04 "Lucid Lynx" - Beta i386 (20100318)
ProcCmdline: glabels
ProcEnviron:
 LANG=en_US.utf8
 SHELL=/bin/bash
Signal: 8
SourcePackage: glabels
StacktraceTop:
 ?? ()
 g_type_create_instance () from /usr/lib/libgobject-2.0.so.0
 ?? () from /usr/lib/libgobject-2.0.so.0
 g_object_newv () from /usr/lib/libgobject-2.0.so.0
 g_object_new () from /usr/lib/libgobject-2.0.so.0
Title: glabels crashed with SIGFPE in g_type_create_instance()
UserGroups: adm admin cdrom dialout lpadmin plugdev sambashare
XsessionErrors: (polkit-gnome-authentication-agent-1:1223): GLib-CRITICAL **: g_once_init_leave: assertion `initialization_value != 0' failed

Revision history for this message
James Kittsmiller (jkittsmiller2) wrote :
visibility: private → public
Changed in glabels (Ubuntu):
status: New → Confirmed
Revision history for this message
Niall Creech (sevenmachines-deactivatedaccount) wrote :

gdb trace

Revision history for this message
theozzlives (theozzlives) wrote :

Crashes when I open a glabels file also

Revision history for this message
Apport retracing service (apport) wrote :

StacktraceTop:
 gl_view_text_init (view_text=0x8a60530) at view-text.c:115
 g_type_create_instance () from /usr/lib/libgobject-2.0.so.0
 ?? () from /usr/lib/libgobject-2.0.so.0
 g_object_newv () from /usr/lib/libgobject-2.0.so.0
 g_object_new () from /usr/lib/libgobject-2.0.so.0

Revision history for this message
Apport retracing service (apport) wrote : Stacktrace.txt
Revision history for this message
Apport retracing service (apport) wrote : ThreadStacktrace.txt
Changed in glabels (Ubuntu):
importance: Undecided → Medium
tags: removed: need-i386-retrace
Revision history for this message
EsbenMoseHansen (kde-mosehansen) wrote :

This appears to be a bug in glibc. From glib/gmem.h

The program crashes on this line:

 view_text->priv = g_new0 (glViewTextPrivate, 1);

And gdb reports

(gdb) p sizeof(glViewTextPrivate)
$1 = 0

expanding g_new0 reveals

#if defined (__GNUC__) && (__GNUC__ >= 2) && defined (__OPTIMIZE__)
# define _G_NEW(struct_type, n_structs, func) \
        (struct_type *) (__extension__ ({ \
          gsize __n = (gsize) (n_structs); \
          gsize __s = sizeof (struct_type); \
          gpointer __p; \
          if (__s == 1) \
            __p = g_##func (__n); \
          else if (__builtin_constant_p (__n) && \
                   __n <= G_MAXSIZE / __s) \
            __p = g_##func (__n * __s); \
          else \
            __p = g_##func##_n (__n, __s); \
          __p; \
        }))

which crashes due to a divide by zero in G_MAXSIZE/__s since __s = sizeof(glViewTextPrivate) = 0.

glViewTextPrivate is defined in view-text.c line 48. As a workaround, I simply added a dummy int to the (obviously empty struct):

struct _glViewTextPrivate {
  int dummy;
};

and again in view-image.c

struct _glViewImagePrivate {
  int dummy;
};

this seems to work. Attaching new diff.gz file.

Revision history for this message
J.L.P. López de Victoria (grupotux-gmail) wrote :

Alpha 3 and subsequent repository updates did not have this problem.

Revision history for this message
Niall Creech (sevenmachines-deactivatedaccount) wrote :

glabels (2.2.7-2ubuntu1) lucid; urgency=low

  * debian/patches/20_no-zero-size-structs:
    Optimisation of glib calls to g_new0 with a zero size object will
    cause a divide-by-zero. So ensure all empty structs have a dummy
    variable so that they're not zero sized. thanks to EsbenMoseHansen
    (LP: #551958)

Changed in glabels (Ubuntu):
assignee: nobody → SevenMachines (sevenmachines)
Revision history for this message
Niall Creech (sevenmachines-deactivatedaccount) wrote :
Revision history for this message
Niall Creech (sevenmachines-deactivatedaccount) wrote :

hold on, theres a few more occasions this problem crops up, i'll do another patch

Revision history for this message
Niall Creech (sevenmachines-deactivatedaccount) wrote :

This should cover the other elements with a 0 struct.

Changed in glabels (Ubuntu):
assignee: SevenMachines (sevenmachines) → nobody
Revision history for this message
wolfen69 (wolfen69) wrote :

Also, glabels will not open when clicking on a .glabels file made with a previous version of glabels. But I also have the problem of glabels shutting down when starting work in it. (as originally reported)

Revision history for this message
Niall Creech (sevenmachines-deactivatedaccount) wrote :

wolfen69: do you still get this problem with the possible test build mentioned previously? if so, can you open a new bug (if you havent already) and attach any info plus a sample old .glabels file

Revision history for this message
J.L.P. López de Victoria (grupotux-gmail) wrote :

Source patched with latest diff and compiled, new deb file installed, PROBLEM SOLVED.

Thank you all very, very much. I use glabels quite frequently.

Anyone wishing to avoid the task of compiling the patched version may reach me at:
<email address hidden>. I'll be pleased to send along the program and its data files in
dot-deb format.

J.L.P.L.

Revision history for this message
Niall Creech (sevenmachines-deactivatedaccount) wrote :

i'm not sure if glib g_new should be handling the zero size case or not to be honest, if someone who knows more about glib could look into that and open a bug on glib if that makes sense. i'll mention this to the glabels people and see what they think at some point

Revision history for this message
wolfen69 (wolfen69) wrote :

SevenMachines: The new build seems to work good after doing a quick check of it. Older .glabels files open correctly, and I was able to work on a new file without it crashing. Will keep you informed if something changes. Keep up the good work.

Revision history for this message
James Kittsmiller (jkittsmiller2) wrote :

SevenMachines: Thank you, your build works great.
Now if we can only get your changes merged upstream..

Revision history for this message
Niall Creech (sevenmachines-deactivatedaccount) wrote :

This is fixed in glabels upstream in 2.2.8 by adding place holder ints as has been done here, so the above patch or upgrading to the new version would both close this. its also been reported to glib as a possible bug
https://bugzilla.gnome.org/show_bug.cgi?id=615379

Revision history for this message
Niall Creech (sevenmachines-deactivatedaccount) wrote :

from debian sid

 glabels (2.2.8-1) unstable; urgency=low

   * New upstream release:
     - Fix crash caused by new g_new macros in glib-2.24.0
     - Removed extra padding in "New label" dialog
     - Updated translations
     - New templates
   * Switch to dpkg-source 3.0 (quilt) format

Changed in glabels (Ubuntu):
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.