gpt4 book ai didi

c - Gtk2 在 64 位机器上崩溃,但在 32 位机器上工作正常

转载 作者:行者123 更新时间:2023-11-30 17:22:34 26 4
gpt4 key购买 nike

我正在开发一个使用 gtk+2 的应用程序。早些时候,我在 32 位 CentOS 6.6 下工作,最近我切换到 64 位 CentOS 6.6,但我的应用程序停止工作。

我已经安装了所有必需库的 32 位版本,我使用 -m32 键编译并链接了我的代码,但我收到了来自库函数的段错误。这是我的程序的输出和 gdb 的回溯:

(main_1:4429): GLib-CRITICAL **: g_io_channel_seek_position: assertion `(error == NULL) || (*error == NULL)' failed(main_1:4429): GLib-WARNING **: g_io_channel_seek_position: unknown seek typeProgram received signal SIGSEGV, Segmentation fault. 0x00a5594b in g_io_channel_seek_position () from /lib/libglib-2.0.so.0 Missing separate debuginfos, use: debuginfo-installPackageKit-gtk-module-0.5.8-23.el6.i686 atk-1.30.0-1.el6.i686cairo-1.8.8-3.1.el6.i686 dbus-glib-0.86-6.el6.i686dbus-libs-1.2.24-7.el6_3.i686 expat-2.0.1-11.el6_2.i686fftw-3.2.1-3.1.el6.i686 fontconfig-2.8.0-5.el6.i686freetype-2.3.11-14.el6_3.1.i686 gdk-pixbuf2-2.24.1-5.el6.i686glib2-2.28.8-4.el6.i686 glibc-2.12-1.149.el6_6.4.i686gtk2-2.24.23-6.el6.i686 gtk2-engines-2.18.4-5.el6.centos.i686libX11-1.6.0-2.2.el6.i686 libXau-1.0.6-4.el6.i686libXcomposite-0.4.3-4.el6.i686 libXcursor-1.1.14-2.1.el6.i686libXdamage-1.1.3-4.el6.i686 libXext-1.3.2-2.1.el6.i686libXfixes-5.0.1-2.1.el6.i686 libXi-1.7.2-2.2.el6.i686libXinerama-1.1.3-2.1.el6.i686 libXrandr-1.4.1-2.1.el6.i686libXrender-0.9.8-2.1.el6.i686 libcanberra-0.22-1.el6.centos.i686libcanberra-gtk2-0.22-1.el6.centos.i686 libogg-1.1.4-2.1.el6.i686libpng-1.2.49-1.el6_2.i686 libselinux-2.0.94-5.8.el6.i686libtdb-1.2.10-1.el6.i686 libtool-ltdl-2.2.6-15.5.el6.i686libvorbis-1.2.3-4.el6_2.1.i686 libxcb-1.9.1-2.el6.i686nss-softokn-freebl-3.14.3-19.el6_6.i686 pango-1.28.1-10.el6.i686pixman-0.32.4-4.el6.i686 zlib-1.2.3-29.el6.i686  (gdb) bt#0  0x00a5594b in g_io_channel_seek_position () from /lib/libglib-2.0.so.0#1  0x0804a07a in main (argc=3, argv=0xffffd334) at main_1.c:108

The warnings above are quite strange because, first of all, I don't receive them when running the app under 32-bit OS and, secondly, because of the code that seems fine:

GError *error = NULL;
sttAppMode.hDataFile = g_io_channel_new_file(data_file_name, "r", &error);
assert(sttAppMode.hDataFile);
g_io_channel_seek_position(sttAppMode.hDataFile, 0, G_SEEK_SET, &error);

什么会导致这种奇怪的行为?

最佳答案

显然

(main_1:4429): GLib-CRITICAL **: g_io_channel_seek_position: assertion `(error == NULL) || (*error == NULL)' failed

这两个失败之一,因此 g_io_channel_new_file (...) 也失败,但仍然返回一个非零值(这是一个错误)。

正确的检查是执行 assert(error==NULL && sttAppMode.hDataFile==NULL) 以确保安全

关于c - Gtk2 在 64 位机器上崩溃,但在 32 位机器上工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27998317/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com