【问题标题】:BadAlloc and crash in wxWidgets program. How to find the error?BadAlloc 和 wxWidgets 程序中的崩溃。如何找到错误?
【发布时间】:2011-01-03 17:26:24
【问题描述】:

我们有一个相当大的跨平台 C++ 程序在 wxWidgets 上运行。最近一大块代码从 windows 移植到 linux,从那时起程序在弹出对话框的显示时崩溃。打印到控制台的错误信息是:

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

但这似乎一直在发生,即使程序运行良好!

【问题讨论】:

    标签: linux debugging wxwidgets x11


    【解决方案1】:

    严重的 GTK 警告绝对不是一件好事,而且通常表明存在问题,因此当您看到它们时,不要以为您的程序运行良好。您可以通过在 gdb 中的 g_log 函数上放置一个断点并在到达那里时查看回溯来调试它们。

    另外,如果您可以在一个简单的示例中使用错误文件 wxMask 重现崩溃,请考虑向 http://trac.wxwidgets.org/ 提交错误报告

    【讨论】:

      【解决方案2】:

      我最终通过使用“--sync”并逐步执行程序找到了它。问题只是给 wxMask 构造函数的路径。如果给wxBitmap同样的错误路径,它只是弹出一个错误信息,但是wxMask没有那么友好。

      【讨论】:

        猜你喜欢
        • 2011-02-22
        • 2013-08-05
        • 2012-03-04
        • 2021-09-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多