News | Forum | People | FAQ | Links | Search | Register | Log in
Help Dissecting/solving A Crash
I decided to try and pick up QuakeC. I'm a beginner coder who hasn't really done serious coding in 20 years, and even then I was a bit of a novice.

I decided to tackle something that while time intensive seemed like an easy first project for learning. I took Seven's amazing SMC 5.4 source code, and the source code for his older Rogue-SMC and decided to try and bring them in line since Rogue-SMC is no longer updated.

My code compiles without errors. I'll looking at warnings, but most seem like red herrings currently, or are the same warnings that vanilla QuakeC produces.

I can start up the game with my compiled progs.dat and the features appear to be working at a glance. But occasionally when I kill a monster, I get a crash. I can upload my source. But here is a crash report:


^7Host_Error: NULL function in server
^7QuakeC crash report for server:
^7s18066: ^3CALL2 ClientObituary (=ClientObituary())
^7s18067: ^1ADDRESS self (=entity 390), takedamage (=.takedamage), GLOBAL17467
^7s18068: ^1STOREP_F IMMEDIATE (=0), GLOBAL17467
^7s18069: ^1ADDRESS self (=entity 390), touch (=.touch), GLOBAL17467
^7s18070: ^1STOREP_FNC SUB_Null (=SUB_Null()), GLOBAL17467
^7s18071: ^3CALL0 monster_death_use (=monster_death_use())
^7s18072: ^6FIELD_FNC self (=entity 390), th_die (=.th_die), GLOBAL17467
^7s18073: ^3CALL0 GLOBAL17467
^7 combat.qc : Killed : statement 48
^7 combat.qc : T_Damage : statement 237
^7 combat.qc : T_RadiusDamage : statement 89
^7 mult_wpn.qc : MiniGrenadeExplode : statement 9
^7Host_ShutdownServer
^7Client "player" dropped
^7CL_Disconnect
^7Sending clc_disconnect
^7CL_Disconnect
^7Host_ShutdownServer
^7OpenGL Backend shutting down
====== Log stopped (Wed Feb 08 11:57:35 2017) ======



And here is another:



^7Host_Error: NULL function in server
^7QuakeC crash report for server:
^7s18066: ^3CALL2 ClientObituary (=ClientObituary())
^7s18067: ^1ADDRESS self (=entity 667), takedamage (=.takedamage), GLOBAL17467
^7s18068: ^1STOREP_F IMMEDIATE (=0), GLOBAL17467
^7s18069: ^1ADDRESS self (=entity 667), touch (=.touch), GLOBAL17467
^7s18070: ^1STOREP_FNC SUB_Null (=SUB_Null()), GLOBAL17467
^7s18071: ^3CALL0 monster_death_use (=monster_death_use())
^7s18072: ^6FIELD_FNC self (=entity 667), th_die (=.th_die), GLOBAL17467
^7s18073: ^3CALL0 GLOBAL17467
^7 combat.qc : Killed : statement 48
^7 combat.qc : T_Damage : statement 237
^7 combat.qc : T_RadiusDamage : statement 89
^7 reiver.qc : reiver_death_touch : statement 22
^7Host_ShutdownServer
^7Client "player" dropped
^7CL_Disconnect
^7Sending clc_disconnect
^7CL_Disconnect
^7Host_ShutdownServer
^7OpenGL Backend shutting down
====== Log stopped (Wed Feb 08 11:09:58 2017) ======


Basically one line is different, but the two crashes and nearly identical. I've looked at ClientObituary() and nothing is jumping out at me. How do I make sense of the crash and troubleshoot my code?


Also, perhaps unrelated I tried compiling the code with the latest win64-fteqccgui.exe and while it compiles, not all of the features appear to be working. I'd assume a newer compiler would be better, but I'm not sure if that is the case. Is there a recommended QCC compiler I should use, and what settings should I use?

Thanks!
Source Code 
 
You say occasionally when you kill a monster the error occurs. Is it any monster class or a specific monster class? 
 
and for future reference we have a coding help thread that this should have been placed in 
Debugging With Fteqccgui 
fteqccgui's debugging features only work with fteqw.
so install fteqw (from http://triptohell.info/moodles/win32/fteglqw.exe typically), change your fteqccgui options to name fteglqw.exe or something instead of dp, recompile, and then hit the debug button (make sure you started it windowed or something). when it then 'crashes', you'll get kicked back to the gui with it highlighting the line that caused the fault.
you can then mouse-over whatever variables you want to inspect their current values.
(breakpoints, single-stepping, all work too).


regarding newer versions of fteqcc, http://triptohell.info/moodles/win32/fteqccgui.exe is the latest.
I do occasionally make tweaks that break compaitibility. This can be either because I fucked up, but I've also made such changes for compatibility or to fix what I see as parsing bugs (eg: old versions treated foo[0] and foo the same way).
regarding the various flags, you shouldn't need to change them from their defaults, in part because noone other than me even knows what most of them do...


regarding dp, it *should* support fteqcc's .lno files, which should give you line numbers instead of just statement indexes. I've no idea why they're not appearing for you. Are you copying files around the place instead of tweaking your progs.src to write the dat to the right directory?


regarding smc, it defines many of its autocvars as locals. this is NOT supported (I've since added a warning to try to discourage this behaviour). Do not try to use any optimisations beyond the defaults because of this, because that would hide them from the engine.


regarding your crash log, inside combat.qc Killed:
ClientObituary();
tmp_17467 = &self.takedamage;
*tmp_17467 = 0;
tmp_17467 = &self.touch;
*tmp_17467 = SUB_Null;
monster_dealth_use(;
tmp_17467 = self.th_die;
tmp_17467(); *CRASH: self.th_die is null*
(I could shorten it to skip the temps which would more closely match your code, but that wouldn't have quite the same meaning)
so find that 'self.th_die();' line inside 'Killed' and add 'print(sprintf("Calling %s th_die\n", self.classname));' just before it 
 
> regarding smc, it defines many of its autocvars as locals. this is NOT supported

I see these compiler warnings. I thought in QuakeC the default for all variables is global.

Can you give an example of how SMC is declaring one of its autocvars as local and how to fix it? There are tons, but with one example I should be able to clean them up in my fork.

When some of the features weren't working, it may have been one of the times I experimented with optimizations in the compiler, not realizing this was effectively hiding autocvar values, and thusly breaking the SMC features. 
 
And it isn't always the same monster, though I'll make sure to copy over the .lno file AND put in the 'print(sprintf("Calling %s th_die\n", self.classname));' as well to catch this.

Thanks! 
 
'just' move all the autocvar definitions outside of the function you find them in.
if they're initialised, make sure they're prefixed with the 'var' keyword too.

also, update your progs.src file so that you don't have to keep copying files all around the place, because copying files every time you recompile is just a waste of your time. 
Ramen 
we need a shub icon badly 
 
Moving the:

var float autocvar_foobar = x

statements out of functions brought my compiler warnings down from something like 540 to 220.

As for the crash, I had it twice quickly last night and then couldn't reproduce it today. But now I'm prepared to track it down if it happens again.

I'd like to get this to compile with as few warnings as possible, but I have noticed that even the vanilla Quake 1.06 code has 103 warnings.

Does that mean that the vanilla code had some bugs or poor practices I should clean up in my version, or are they basically benign and red herrings? 
 
the vanilla qcc had no warnings, for anything.
assigments to constants! sure, go ahead! 5=3; yup, fine. and folding means that it'll go and screw up all the other constants with the same value. there's loads of unused variables too.
most of them are easy/trivial to fix, but the th_pain assignments are more annoying. you can just add casts for those, if you're feeling lazy. 
Vanilla Quake Warnings 
Maybe with the original compiler, but I try to compile vanilla 1.06 with the latest win64-fteqccgui.exe I get 103 warnings. At least a few of these look like they might be legit problems to clean up.

ai.qc:302: warning F210: Sound "vomitus/v_sight1.wav" was used but not directly precached - This seems like a legit vanilla bug. If I attempt to precache it, it says the file does not exist.

fight.qc:299: warning F306: Local "enemy_yaw" hides global with same name and type - enemy_yaw is defined locally and globally in the same file. This seems like an oversight.

ai.qc:368: warning Q203: 'FindTarget' returned nothing, expected float
ai.qc:588: warning Q203: 'CheckAnyAttack' returned nothing, expected float

weapons.qc:92: warning Q207: org duplicate definition ignored

misc.qc:179: warning Q205: Statement does not do anything

knight.qc:32: warning: Duplicate macro defined (attackb1)
oldone.qc:29: warning: Duplicate macro defined (shake12)

enforcer.qc:76: warning Q207: vec duplicate definition ignored

defs.qc:401: warning Q302: float empty_float no references.
fight.qc:298: warning Q302: float chance no references.
fight.qc:299: warning Q302: float enemy_yaw no references.
ai.qc:37: warning Q302: float current_yaw no references.
ai.qc:476: warning Q302: vector mtemp no references.
ai.qc:476: warning Q302: float mtemp_x no references.
ai.qc:476: warning Q302: float mtemp_y no references.
ai.qc:476: warning Q302: float mtemp_z no references.
ai.qc:679: warning Q302: vector delta no references.
ai.qc:679: warning Q302: float delta_x no references.
note: suppressed 68 more warnings about unreferenced variables, as you clearly don't care about the first 10.

client.qc:507: warning F307: type mismatch: void() player_pain to void(entity attacker, float damage) self.th_pain - I've got a bunch of these
doors.qc:581: warning F307: type mismatch: void() SUB_Null to void(entity attacker, float damage) self.th_pain
doors.qc:668: warning F307: type mismatch: void() fd_secret_use to void(entity attacker, float damage) self.th_pain
doors.qc:772: warning F307: type mismatch: void() fd_secret_use to void(entity attacker, float damage) self.th_pain
dog.qc:357: warning F307: type mismatch: void() dog_pain to void(entity attacker, float damage) self.th_pain
shalrath.qc:233: warning F307: type mismatch: void() shalrath_pain to void(entity attacker, float damage) self.th_pain
oldone.qc:277: warning F307: type mismatch: void() nopain to void(entity attacker, float damage) self.th_pain

subs.qc:25: warning Q206: SetMovedir: not all control paths return a value - I've got a bunch of these that a glance appear to be benign
client.qc:134: warning Q206: FindIntermission: not all control paths return a value
wizard.qc:180: warning Q206: WizardAttackFinished: not all control paths return a value

items.qc:47: warning Q105: too few parameters on call to droptofloor - I have tons of these as well
monsters.qc:75: warning Q105: too few parameters on call to droptofloor
misc.qc:249: warning Q105: too few parameters on call to droptofloor
misc.qc:281: warning Q105: too few parameters on call to droptofloor
misc.qc:536: warning Q105: too few parameters on call to makestatic
ogre.qc:249: warning Q105: too few parameters on call to ai_charge 
Post A Reply:
Name:
Title:
Body:
message
question
exclamation
idea
flame
noflame
error
skull
beer
moon
pent
rocket
sheep
pacman
pig
cheese
worldcraft
gauntlet
crate
pitfall
pimp
smile
cool
sad
frown
oi
yay
tongue
evil
wink
neutral
q1
q2
q3
ut
hl
cs
doom
dkt
serious
cube
Website copyright © 2002-2017 John Fitzgibbons. All posts are copyright their respective authors.