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

时间:2015-01-17 09:59:43

标签: c linux gtk gtk2

我正在开发一个使用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 type

Program received signal SIGSEGV, Segmentation fault.
 0x00a5594b in g_io_channel_seek_position () from /lib/libglib-2.0.so.0
 Missing separate debuginfos, use: debuginfo-install
PackageKit-gtk-module-0.5.8-23.el6.i686 atk-1.30.0-1.el6.i686
cairo-1.8.8-3.1.el6.i686 dbus-glib-0.86-6.el6.i686
dbus-libs-1.2.24-7.el6_3.i686 expat-2.0.1-11.el6_2.i686
fftw-3.2.1-3.1.el6.i686 fontconfig-2.8.0-5.el6.i686
freetype-2.3.11-14.el6_3.1.i686 gdk-pixbuf2-2.24.1-5.el6.i686
glib2-2.28.8-4.el6.i686 glibc-2.12-1.149.el6_6.4.i686
gtk2-2.24.23-6.el6.i686 gtk2-engines-2.18.4-5.el6.centos.i686
libX11-1.6.0-2.2.el6.i686 libXau-1.0.6-4.el6.i686
libXcomposite-0.4.3-4.el6.i686 libXcursor-1.1.14-2.1.el6.i686
libXdamage-1.1.3-4.el6.i686 libXext-1.3.2-2.1.el6.i686
libXfixes-5.0.1-2.1.el6.i686 libXi-1.7.2-2.2.el6.i686
libXinerama-1.1.3-2.1.el6.i686 libXrandr-1.4.1-2.1.el6.i686
libXrender-0.9.8-2.1.el6.i686 libcanberra-0.22-1.el6.centos.i686
libcanberra-gtk2-0.22-1.el6.centos.i686 libogg-1.1.4-2.1.el6.i686
libpng-1.2.49-1.el6_2.i686 libselinux-2.0.94-5.8.el6.i686
libtdb-1.2.10-1.el6.i686 libtool-ltdl-2.2.6-15.5.el6.i686
libvorbis-1.2.3-4.el6_2.1.i686 libxcb-1.9.1-2.el6.i686
nss-softokn-freebl-3.14.3-19.el6_6.i686 pango-1.28.1-10.el6.i686
pixman-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

上面的警告很奇怪,因为首先,我在32位操作系统下运行应用程序时没有收到它们,其次,因为代码似乎很好:

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);

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

1 个答案:

答案 0 :(得分:0)

显然

(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)安全