project-navigation
Personal tools

Author Topic: Help needed on weird crash  (Read 5492 times)

Offline Yatta

  • Rookie
  • ***
  • Posts: 57
    • View Profile
Help needed on weird crash
« on: March 20, 2010, 06:27:12 pm »
Hello, im having trouble with my custom build, the game crashes, but all I get from the callstack is this :



Its not always exactly the same error, but always a nt*** gibberish, or sometimes I get a correct callstack pointing to TR_TestLine_R, but I couldnt find anything wrong in that.

I hope someone can give me a clue on what to do to correct that crash, because im lost.

Offline Duke

  • Administrator
  • PHALANX veteran
  • *****
  • Posts: 1037
    • View Profile
Re: Help needed on weird crash
« Reply #1 on: March 20, 2010, 09:18:28 pm »
Looks like a corrupted stack.
Do you know how to use the debugger ?

Offline Yatta

  • Rookie
  • ***
  • Posts: 57
    • View Profile
Re: Help needed on weird crash
« Reply #2 on: March 20, 2010, 09:40:41 pm »
if you mean break points and step by step, yes. But when you stop the debugger, and have a for example an edict_t "ent" in the function, the debugger gives you a memory address for "ent" (well i suppose its an address), but is it possible to see the object's values from there (for exemple, the "ent"->pos) ?

Anyways, its hard to debug, I couldnt find a precise case where it will systematically happen. Sometimes it crashes at first round, other times I can play a dozen rounds before it crashes.

Well I guess ill just have to be very patient. Its either that or rewrite the whole code from a clean version, regularly testing with a full match to see if things go bad. I already used turtoise file comparison to check exactly what change i did to files, and couldnt really find anything suspicious.

Offline Duke

  • Administrator
  • PHALANX veteran
  • *****
  • Posts: 1037
    • View Profile
Re: Help needed on weird crash
« Reply #3 on: March 21, 2010, 12:47:27 am »
if you mean break points and step by step, yes. But when you stop the debugger, and have a for example an edict_t "ent" in the function, the debugger gives you a memory address for "ent" (well i suppose its an address), but is it possible to see the object's values from there (for exemple, the "ent"->pos) ?
Yes. Are you using Code::Blocks ? Try adding a watch on ent->pos.

You said somewhere that you're not too familiar with C. What is the language that you usually use ?


Offline Yatta

  • Rookie
  • ***
  • Posts: 57
    • View Profile
Re: Help needed on weird crash
« Reply #4 on: March 21, 2010, 10:13:30 am »
I dont "usually" use any specific language - Since I was young I used various languages depending on what I do I use php, javascript, blitzbasic, various game scripting tools (kismet for Unreal engine for instance), and worked in the video game industry as a game/level designer. This is why im not unconfortable with languages structures, programming logic and game logic in general.

However, for some reason I never really did "serious" coding with C languages - well to be honest I only like to code game logic, and blitzbasic is perfect for that, the 3D engine is all ready, you can do pretty much anything you want with it, altough its basic, it is object oriented ... so I didnt feel the need to switch (also setting up a dev env for coding / compiling always kinda annoyed me).

So, UFO:AI kinda is my first step into 'serious' coding.

And thanks for the value watch, ill be using that.

Offline Duke

  • Administrator
  • PHALANX veteran
  • *****
  • Posts: 1037
    • View Profile
Re: Help needed on weird crash
« Reply #5 on: March 21, 2010, 10:40:59 pm »
Ok, if you come from scripting languages, here are a couple of common 'traps' in C:
- C is very touchy in regards to the size of variables
- strings are null-terminated, ie. one bye longer than they look
- you should really know what a 'pointer' is

For example:
Code: [Select]
int foo() {
char aaa[4];
strcpy(aaa,"four");
}
can cause a corrupted stack like in the initial post of this thread.

Offline Yatta

  • Rookie
  • ***
  • Posts: 57
    • View Profile
Re: Help needed on weird crash
« Reply #6 on: March 21, 2010, 11:17:48 pm »
Now this is interesting information. Basically that corrupted call stack is saying ive messed up with memory at some point ?

I checked all my function and function calls to make sure I wasnt sending new objects instead of pointers, it seems ok.
I didnt manipulate strings until I started adding notes for debugging, only one manipulation that I just removed.

Can warnings cause actual problems ? I have warnings on unused values, warning: format '%i' expects type 'int', but argument 3 has type 'double' (when using "gi.BroadcastPrintf(PRINT_CONSOLE ..." function), and finally an "implicit declaration" of a function.

I know warning arent good, but are they bad and more importantly, could they be related to my problem ?

Anyways, im trying new things with what you told me. Thanks, because i've been stuck for 3 days now.

Offline Duke

  • Administrator
  • PHALANX veteran
  • *****
  • Posts: 1037
    • View Profile
Re: Help needed on weird crash
« Reply #7 on: March 21, 2010, 11:43:14 pm »
Now this is interesting information. Basically that corrupted call stack is saying ive messed up with memory at some point ?
Probably yes. Google for 'buffer overflow' to get an idea.

Can warnings cause actual problems ?
Definitely. Basically, the compiler is asking you "are you really sure what you are doing there??".

I have warnings on unused values, warning: format '%i' expects type 'int', but argument 3 has type 'double' (when using "gi.BroadcastPrintf(PRINT_CONSOLE ..." function), and finally an "implicit declaration" of a function.
unused values - uncritical
implicit declaration - it depends; usually not
%i for double - *very* critical (depending on the rest of the statement) because it's 4 bytes versus 8 byte (see above).
Size DOES matter ;)


Offline Yatta

  • Rookie
  • ***
  • Posts: 57
    • View Profile
Re: Help needed on weird crash
« Reply #8 on: March 22, 2010, 12:09:45 am »
Sir Duke, im 89.4% sure i love you.

I could just play 3 full missions without a crash. The crash was random so i cant be 100% sure its gone, but since I could barely play a full mission so far, it is now very likely.

I now have to resolve a TU bug (using more TU than possible, resulting in 255 TU added -> FLASH ! OOOhoooo ...) and tweak and balance a little, then ill be able to show the result of my work ;)

Offline Duke

  • Administrator
  • PHALANX veteran
  • *****
  • Posts: 1037
    • View Profile
Re: Help needed on weird crash
« Reply #9 on: March 22, 2010, 12:17:47 am »
:)