我們有一個在wxWidgets上運行的相當大的跨平臺C++程序。最近,一大塊代碼從windows移植到linux,從那以後,程序在顯示彈出對話框時崩潰。打印到控制檯的錯誤信息是:BadAlloc在wxWidgets程序中崩潰。如何找到錯誤?
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.
步進通過與調試器的代碼,違規線似乎是:
wxBitmap* maskBmp = new wxBitmap(iconPath, wxBITMAP_TYPE_BMP);
wxMask* mask = new wxMask(*maskBmp, wxColour(255, 0, 255));
在崩潰的第二行之後。位圖顯示爲正確加載,因爲在工具欄的其他位置使用相同的圖標沒有任何問題。我試圖用「--sync」進行調試,因爲錯誤消息提示,但這似乎沒有多大幫助,因爲gdb似乎無法在gdk_x_error()函數上放置斷點。
有關錯誤可能來自哪裏或至少如何跟蹤它的任何想法?
感謝
更新:請注意,我得到一個日誌Xwindows下的斷言錯誤的,如:
(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
但這似乎發生的時間,即使在程序運作良好!