Game Development Community

Segment fault when starting SDK

by Robert Norris · in Torque Game Engine · 08/30/2005 (3:28 am) · 13 replies

Hi,

i've compiled the SDK on my Linux Server (dedicated) after adding some new files (*.cc, *.h) There were no compilation errors, but when i try to start the dedicated server, i get an "segment fault" error message... nothing more.
I enabled the -console option, but nothing appears except the "segment fault" error.

On my local windows machine the server build works fine (i havn't much experience with linux)

Any suggestion what i can do to get more information about the problem or how i can fix it?

best regards
rob

#1
08/30/2005 (5:32 am)
Does this happen after a make clean; make dedicated run?
#2
08/30/2005 (11:40 pm)
Yes, it does.

Perhaps this is the problem:
I mainly work on windows and so installed the windows distribution of the SDK on my local machine. Later i've leased a linux server which i use for CVS and (now) as a dedicated game server.
For the Linux compilation i've checked out the engine from my CVS repository (windows distribution, imported from my local machine), because i've changed several files of the engine and wanted them to be compiled too... are there critical file-differerences between the Windows and the linux distribution concerning the engine?
I don't think so, but who knows...?
#3
08/30/2005 (11:45 pm)
I know that there are some file differences between the windows and mac distros which can be bad, but all of those get caught by the compiler in my experience. Don't know about linux and windows, but I would assume that there are some differences as well.
#4
08/31/2005 (12:30 am)
It would be helpful to know which files are different, because i don't want to make redundant work by doing all the changes to the engine-files twice -> in my windows- and a seperate linux repository...
(i always try to avoid changes to the engine, but sometimes...)

UPDATE:
Ok, i've installed and compiled the linux distribution of the SDK on my server and it works fine. i will try to get it running with my engine changes.
#5
08/31/2005 (2:07 am)
Mac/windows/linux builds can coexist in the same repo with Torque. It's all done with #ifdefs and different project files. Speaking of project files, did you update yours to include the new files, on all the build systems you're using?
#6
08/31/2005 (2:19 am)
Due to the fact that i'm not sure what you're talking about, i think that i didn't update any project file for linux (i only added my new files to the target.torque.mk file). Can you explain this a bit more?
#7
08/31/2005 (2:34 am)
That's the file you have to add things to for linux (ie, the GCC tools).
#8
08/31/2005 (5:24 am)
Ok, i'm a noob on linux. I know how to copy files, change a directory, write perl scripts and so on, but i never compiled a c++ project on a linux platform before. I used the torque documentation to run the dedicated server build of the torque SDK. As described above, this build works fine (See "UPDATE" three posts ago).

I've now added my changed files to the engine directory(vehicle.cc/.h, guiCrossHairHud.cc, projectile.cc/.h, simManager.cc, simBase.cc/.h and consoleType.h) and then added my own, new files. I modified the .mk files by adding entries for my new files and started building (make clean, make dedicated). All files were compiled (including my own, new files), but i get some warnings of that kind:
droid.cc:No newline at end of file.

When i start the linked .bin i get the segment fault...
droid.cc is one of my new files. Could a newline conflict cause such an error?

UPDATE:
Roll back: It's not the dedicated server build that runs fine, it's the normal torqueDemo.bin of the SDK which comes with the linux distribution that runs fine (using the -dedicated option). The dedicated server build torqueDemod.bin also causes a segment fault when starting...
#9
08/31/2005 (3:22 pm)
You'll have to break out the debugger and start tracing down the problem, I fear.
#10
08/31/2005 (5:27 pm)
Does it dump core?

If not, try

ulimit -c unlimited
or
ulimit -c 1000000000
(or other large number).

Then run it again to see if it dumps core.

If it does, do this:

gdb -c corefile torqueDemod.bin

when gdb finishes loading type "bt" to get the backtrace, this might help you find out where it is crashing.
#11
09/01/2005 (12:47 am)
Thanks for the detailed description!

After i typed in "ulimit -c unlimited" the segment fault error was expanded by "(core dump)".

So i folloewd your steps an used gdb and later "bt". Here is the output (since starting gdb):

gaser@h560370:~/projects/torque/example> gdb -c core.13251 ./torqueDemod.bin
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i586-suse-linux"...Using host libthread_db library "/lib/tls/libthread_db.so.1".

Core was generated by './torqueDemod.bin -dedicated'.
Program terminated with signal 11, Segmentation fault.

warning: current_sos: Can't read pathname for load map: Eingabe-/Ausgabefehler

Reading symbols from /usr/lib/libogg.so.0...Reading symbols from /usr/lib/debug/usr/lib/libogg.so.0.5.2.debug...done.
done.
Loaded symbols for /usr/lib/libogg.so.0
Reading symbols from /usr/lib/libvorbis.so.0...Reading symbols from /usr/lib/debug/usr/lib/libvorbis.so.0.3.0.debug...done.
done.
Loaded symbols for /usr/lib/libvorbis.so.0
Reading symbols from /lib/tls/libpthread.so.0...done.
Loaded symbols for /lib/tls/libpthread.so.0
Reading symbols from /usr/lib/libstdc++.so.5...done.
Loaded symbols for /usr/lib/libstdc++.so.5
Reading symbols from /lib/tls/libm.so.6...done.
Loaded symbols for /lib/tls/libm.so.6
Reading symbols from /lib/libgcc_s.so.1...done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /lib/tls/libc.so.6...done.
Loaded symbols for /lib/tls/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
#0  0x40203c18 in clone () from /lib/tls/libc.so.6
(gdb) bt
#0  0x40203c18 in clone () from /lib/tls/libc.so.6
#1  0x003d0f00 in ?? ()
#2  0x00000000 in ?? ()
#3  0x40053a20 in __nptl_deallocate_tsd () from /lib/tls/libpthread.so.0
#4  0x00000000 in ?? ()

does this help?

UPDATE:
i've made a dedicated debug build of the SDK including my project. Then i started "./*d_DEBUG.bin -dedicated" and it works fine. So the segment fault only occurs in RELEASE Mode... but this doesn't make it better, because running a game server in debug mode isn't what i want to do ;)
#12
09/01/2005 (8:45 am)
Ugh, release mode segfault. The stack trace is thus useless. You could try turning down the optimization level in the makefile (conf.UNIX.mk) from -O2 to -O1 or even remove the -O entirely. -O2 in particular has been known to cause segfaults with some gcc/code combinations. Its hard to say whether the problem is with torque itself or with your game code; I haven't checked the dedicated server only build in quite some time.

If its still crashing even if you turn off optimization, I would try looking for a memory error in the code. You can do this by defining TORQUE_DISABLE_MEMORY_MANAGER in platform.h and then doing a clean rebuild, and then re-running it. If you have a memory error you should see it crash in the debug build too, and then you can run gdb on the debug core dump and hopefully get a meaningful stack trace.
#13
09/01/2005 (11:53 pm)
John, you got it!

Setting down the optimization level from -O2 to -O1 fixed the problem. The SDK (including my projectfiles) runs in release mode now.

Thank you so much for your detailed descriptions and another special thanks goes to Ben, Alex and Gregory for their answers!

best regards
rob

p.s.: Hm... the client can't find the server, but i can do a lot of things before i start a new thread ;)