Game Development Community

Crashes During Preload on FreeBSD, not on Mac

by Charlie Sibbach · in Torque Game Engine · 10/16/2005 (5:48 pm) · 5 replies

Hey all,

We decided to ditch the RTS kit and revert to the standard TGE, as our game is closer to the FPS than the RTS. We'll be using alot of bits and pieces from the RTS, though.

Anyway, all has been going well- the standard TGE fixed my connection bug and saved my scalp alot of wear and tear. I've divided up the data/shapes/player stuff so that I can have multiple player models, tested it, and it works- multiple datablocks and some name changes, little stuff. Next, I implemented the Custom Shape mod, which allows scaling of the model per bone. It compiles just fine, no errors. But now, I get a segfault after preloading the DTS model- on BSD only, not on MacOSX. I haven't tried it on Windows yet, I'm doing most of the development on these two systems. Here's what I get on BSD, as it loads the dedicated server:

--------- Starting Dedicated Server ---------
Exporting server prefs...
Starting multiplayer mode
Binding server port to default IP
UDP initialized on port 28000
Listenning on port: 28000
Loading compiled script midnightoil/server/scripts/audioProfiles.cs.
...
Loading compiled script midnightoil/server/scripts/radiusDamage.cs.
Loading compiled script midnightoil/server/scripts/crossbow.cs.
ParticleEmitterData(CrossbowBoltEmitter) velocityVariance > ejectionVelocity
Error: shape midnightoil/data/shapes/crossbow/ammo.dts-collision detail 0 (Collision-3) bounds box invalid!
Loading compiled script midnightoil/server/scripts/player.cs.
Loading compiled script midnightoil/data/shapes/player/player.cs.
Validation required for shape: midnightoil/data/shapes/player/Orc/orc_player.dts
% Segmentation fault (core dumped)

On OSX, it continues fine:

--------- Starting Dedicated Server ---------
Exporting server prefs...
CreateDirectory(common/) - Succeeded
Starting multiplayer mode
Listenning on port: 28000
Loading compiled script midnightoil/server/scripts/audioProfiles.cs.
...
Loading compiled script midnightoil/server/scripts/crossbow.cs.
ParticleEmitterData(CrossbowBoltEmitter) velocityVariance > ejectionVelocity
Error: shape midnightoil/data/shapes/crossbow/ammo.dts-collision detail 0 (Collision-3) bounds box invalid!
Loading compiled script midnightoil/server/scripts/player.cs.
Loading compiled script midnightoil/data/shapes/player/player.cs.
Validation required for shape: midnightoil/data/shapes/player/Orc/orc_player.dts
Validation required for shape: midnightoil/data/shapes/player/Glowy/glowy_player.dts
Loading compiled script midnightoil/server/scripts/chimneyfire.cs.
Loading compiled script midnightoil/server/scripts/aiPlayer.cs.
Validation required for shape: midnightoil/data/shapes/player/Orc/orc_player.dts
*** LOADING MISSION: midnightoil/data/missions/stronghold.mis
*** Stage 1 load
*** Stage 2 load
Executing midnightoil/data/missions/stronghold.mis.
*** Mission loaded
Engine initialized...
Sending heartbeat to master server [IP:216.116.32.49:28002]
Received info request from a master server [IP:216.116.32.49:28002].

The "Listenning on port:" part is something I added in script, because the Mac side does not report the UDP Initialized message. Both systems are running the same codebase, synched with CVS, so it's not a problem of having code on one side that I don't have on the other. Anybody have any ideas on this?

#1
10/16/2005 (9:51 pm)
I reverted back to the pre-mod days, and it works again. Has anybody else had trouble with the custom shape mod on Linux? I'll probably try it again later and do it by hand so I can make sure it's right this time.

I did a backtrace on the core dump (best I can do with command line gdb), and it crashed somewhere in a pthread call, for what it's worth.
#2
10/18/2005 (1:17 pm)
I felt pretty good there for a while after rolling it back, and I decided to skip that mod for a while and focus on my PeerConnection code. Well, the segfault is back, in a different place. Now, it faults after the mission is loaded- right after the "Engine Initialized" message. The output is below. I actually used a clean copy of the starter.fps, so I'm pretty sure it's not a script problem:

...
Validation required for shape: starter.fps/data/shapes/player/player.dts
*** LOADING MISSION: starter.fps/data/missions/stronghold.mis
*** Stage 1 load
*** Stage 2 load
Executing starter.fps/data/missions/stronghold.mis.
*** Mission loaded
Engine initialized...
% Segmentation fault (core dumped)

It only does the segfault if the mission is actually loaded. If I specify an invalid mission, it goes along just fine and dandy:

...
Validation required for shape: starter.fps/data/shapes/player/player.dts
*** LOADING MISSION: starter.fps/data/missions/stronghold.mi
*** Stage 1 load
*** Stage 2 load
Could not find mission starter.fps/data/missions/stronghold.mi
Engine initialized...
Sending heartbeat to master server [IP:216.116.32.49:28002]
Received info request from a master server [IP:216.116.32.49:28002].

And again, it doesn't do this on OSX. The only change I've made to the engine source code is to add a new class, a heavily stripped down variant of GameConnection. The script doesn't even execute this code! I haven't tested it on the Linux kernal, but I suspect I'll have the same problem.

Has anybody else experienced extreme fragility issues on Linux/BSD? I'm feeling extremely frustrated, as I think I understand the code and the architecture, I feel comfortable making changes, yet every change I make seems to break the BSD/Linux version. This wouldn't be so maddenning if it also broke the Mac/Windows versions too... Any ideas?
#3
10/18/2005 (10:01 pm)
Turns out the segfault was due to an incorrectly built executable. After cleaning and a fresh rebuild, low and behold it stopped crashing. How and why it was built incorrectly, I have no idea.... At least now I know how to fix the problem if it happens again.

On an upbeat note, I also figured out why the PeerConnection code wasn't working; it was an equally lame problem- I hadn't called setNetPort() before trying to make the connection. Hell, it even works, so I'm cleaning it up for testing and release as a resource.

Sorry to vent here on the forums; I'm just running up against my deadline and losing a day or two unnecessarily is just more than I can handle after midnight and a few hours of frantic debugging.
#4
10/18/2005 (10:49 pm)
Not a problem :) Some of us answer our own questions/issues after we take the time to write them down in a coherent manner on the forums--I've gotten into the habit of emailing myself actually, explaining the problem in full, then walking away to get distracted for a few minutes. Many times when I come back and read the email it hits me.

Would be good to hear at least what you do to fix the issue when you see it--that way if someone else happens to have the same or similar issue, they can read it here :)
#5
10/20/2005 (2:56 pm)
I figured out exactly why the crash occured and why it didn't show up in the debugger as something obvious, so for future reference I'll explain it here.

Long story short: the make system for Linux isn't set up to calculate header dependencies. I had changed header files that were important to .cc files that were not being recompiled. This screwed up the linker, and ended with mystery segfaults. This is one of those things that is obvious in hindsight, but maddenning at the time.

Moral of the story: after changing a header file on Linux/BSD, and you aren't absolutely sure all .cc files dependent on it are going to be rebuilt, clean before you build.