views:

132

answers:

2

Hello,

We have a fairly large cross-platform C++ program running on wxWidgets. Recently a big chunk of code was ported over from windows to linux, and since then the program crashes upon the display of a pop-up dialog. The error message printed to the console is:

The program 'program name' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadAlloc (insufficient resources for operation)'.
  (Details: serial 12425 error_code 11 request_code 53 minor_code 0)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)
libxcb: WARNING! Program tries to lock an already locked connection,
        which indicates a programming error.
        There will be no further warnings about this issue.

Stepping through the code with a debugger, the offending lines seem to be:

wxBitmap* maskBmp = new wxBitmap(iconPath, wxBITMAP_TYPE_BMP);
wxMask* mask  = new wxMask(*maskBmp, wxColour(255, 0, 255));

After the second line in crashes. The bitmaps appear to load correctly, since the same icons are used elsewhere in a toolbar without any problems. I have tried to debug with "--sync" as the error message suggests, but this doesn't seem to help much, since gdb can't seem to put a breakpoint on the gdk_x_error() function.

Any ideas on where the error might be coming from, or at least how to track it down?

Thanks

UPDATE: Note that I get a log of xWindows assertion errors like :

(main:5322): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed

(main:5322): Gdk-CRITICAL **: gdk_drawable_get_image: assertion `GDK_IS_DRAWABLE (drawable)' failed

(main:5322): Gdk-CRITICAL **: gdk_image_get_colormap: assertion `GDK_IS_IMAGE (image)'failed

(main:5322): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed

but this seems to happen all the time, even when the program is working well!

A: 

Well I ended up finding it by using "--sync" and stepping through the program. The problem was simply the path given to the wxMask constructor. If the same wrong path is given to wxBitmap, it just pops up an error message, but wxMask is not as friendly.

drpepper
+1  A: 

Critical GTK warnings are definitely not a good thing and often indicate a problem so don't assume that your program is working well when you see them. You can debug them by putting a breakpoint on g_log function in gdb and looking at the backtrace when you get there.

Also, if you can reproduce a crash with using a wrong file with wxMask in a simple example, please consider submitting a bug report to http://trac.wxwidgets.org/

VZ