Game Development Community

Linux Build seg-faulting

by Thomas -elfprince13- Dickerson · in Torque Game Engine · 09/13/2009 (3:22 am) · 10 replies

Both my debug and release builds of (lightly modified) TGE compile fine under Linux, but segfault when I try to run them.

Here's the output from doing a backtrace in GDB:

(gdb) bt
#0  0x00000000 in ?? ()
#1  0x083e242d in XOpenDisplay ()
#2  0x083262e3 in DetectWindowingSystem () at /home/thomas/cb_lnx_tge15/engine/platformX86UNIX/x86UNIXWindow.cc:136
#3  0x083276d0 in main (argc=1, argv=0xffa23fb4) at /home/thomas/cb_lnx_tge15/engine/platformX86UNIX/x86UNIXWindow.cc:883

here's the code in the relevant functions

static void DetectWindowingSystem()
{
#ifndef DEDICATED
   Display* dpy = XOpenDisplay(NULL);
   if (dpy != NULL)
   {
      x86UNIXState->setXWindowsRunning(true);
      XCloseDisplay(dpy);
   }
#endif
}

About the author

C.S. PhD student at Brown University. Project lead for FreeBuild. Administrator, Cemetech tech community. Webmaster for the Village2Village Projects and the Vermont Sustainable Heating Initiative.


#1
10/10/2009 (1:47 pm)
So....any help on this?
#2
10/10/2009 (2:04 pm)
Looks like a problem with the xlib on your system.
#3
10/10/2009 (2:09 pm)
Sorry, no clue. That's really not much to go on. What was the error that gdb spit out before you ran the backtrace? Compiling with GCC? What version? Which distro?
#4
10/10/2009 (2:53 pm)
I'm compiling with gcc 4 under 64-bit Ubuntu using /lib32 and -m32 to target 32-bit Linux.
#5
10/10/2009 (5:17 pm)
I'm told that many 64 bit distros do no include 32 bit libraries by default. You'll need to install the 32 bit libraries if you want to run a 32 bit build on your 64bit system. I'd guess that's probably the source of your problem.
#6
10/10/2009 (9:22 pm)
I already spent a long time doing that, and compiling a lot of extra libraries for 32-bits as well. It wouldn't even have linked successfully if I hadn't.
#7
10/10/2009 (10:19 pm)
Well shoot. I'm out of ideas then. I assume you have the 32bit libraries installed properly for runtime use, not just the development files?

... Wasn't there a point release of GCC 4 that broke binary compatibility with older GCC 4? or am I thinking of something else..
#8
10/10/2009 (11:28 pm)
For the most part, I'm using static libraries. I'm not sure but doesn't broken binary compatibility also usually mean problems in linking?
#9
10/11/2009 (3:41 am)
Honestly, I'm not sure. I think it's possible to link successfully and still encounter problems at run time, but I really haven't looked into it.

Thing is, the code in question looks to me to be too simple to be a flaw in the way Torque is trying to use X, and I'm assuming other apps on your system are making similar X calls successfully. So I'm thinking it's a GCC version compatibility issue; if only because that's all I can think of. I could be way off.

I have this vague memory of there having been some issues with GCC 4.2 vs 4.3, though I could be imagining it. Do you know if you're using the same GCC version that your libraries were compiled with?

Also, I'm looking at my conf.UNIX.mk and I'm noticing several full paths to the X libraries (/usr/X11R6/ in my case). You've probably checked this, but since you have multiple libraries on your system (32/64) are you linking against the correct one?
#10
10/11/2009 (11:33 am)
Ok. I do know it's not possible to use the -m32 flag and link against 64 bit libraries, because they actually use different file formats and ld lets you know. I'll try and look into the 4.2/4.3 issues, and anything that might be going on with the X11 libraries.