简体   繁体   中英

Gtk2 crashes on 64-bit machine but works fine on 32-bit

I'm developing an application that uses gtk+2. Earlier I was working under 32-bit CentOS 6.6 and recently I've switched to 64-bit CentOS 6.6 and my appllication stopped working.

I have installed 32-bit versions of all required libraries, I compile and link my code with -m32 key, but I receive a segfault from the library function. Here's the output of my program and backtrace from 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

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

What could cause such a strange behaviour?

Obviously

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

one of those two fails, and thus g_io_channel_new_file (...) failed as well but still did return a nonzero value (which is a bug).

the proper check would be to do assert(error==NULL && sttAppMode.hDataFile==NULL) to be safe

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM