Bug 2367 - SIGSEGV in Team_SetFlagStatus at game/g_team.c:225
Status: RESOLVED FIXED
Alias: None
Product: ioquake3
Classification: Unclassified
Component: Platform
Version: 1.33 SVN
Hardware: PC Linux
: P2 normal
Assignee: Zachary J. Slater
QA Contact: ioquake3 bugzilla mailing list
URL:
Depends on:
Blocks:
 
Reported: 2005-09-05 11:12 EDT by Serge Belyshev
Modified: 2007-05-21 11:23:27 EDT
0 users

See Also:



Description Serge Belyshev 2005-09-05 11:12:33 EDT
On amd64, quake3 crashes on any ctf map in team arena mode:

g_team.c:50:
		teamgame.redStatus = teamgame.blueStatus = -1; // Invalid to force update
		Team_SetFlagStatus( TEAM_RED, FLAG_ATBASE );
		Team_SetFlagStatus( TEAM_BLUE, FLAG_ATBASE );

both teamgame.redStatus and teamgame.blueStatus set to -1 before first call to
Team_SetFlagStatus(), and then:

g_team.c:224:
			st[0] = ctfFlagStatusRemap[teamgame.redStatus];
			st[1] = ctfFlagStatusRemap[teamgame.blueStatus];

both are used to index ctfFlagStatusRemap[] but only one of them is set to real
value, so we're getting:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 46912510282464 (LWP 4154)]
0x00002aaab55da405 in Team_SetFlagStatus (team=1, status=FLAG_ATBASE) at
../game/g_team.c:225
225				st[1] = ctfFlagStatusRemap[teamgame.blueStatus];
(gdb) p teamgame.blueStatus
$4 = 4294967295
(gdb) p teamgame.redStatus
$5 = FLAG_ATBASE

Here is a simple fix:

Index: code/game/g_team.c
===================================================================
--- code/game/g_team.c	(revision 84)
+++ code/game/g_team.c	(working copy)
@@ -47,8 +47,9 @@
 
 	switch( g_gametype.integer ) {
 	case GT_CTF:
-		teamgame.redStatus = teamgame.blueStatus = -1; // Invalid to force update
+		teamgame.redStatus = -1; // Invalid to force update
 		Team_SetFlagStatus( TEAM_RED, FLAG_ATBASE );
+		teamgame.blueStatus = -1; // Invalid to force update
 		Team_SetFlagStatus( TEAM_BLUE, FLAG_ATBASE );
 		break;
 #ifdef MISSIONPACK
Comment 1 Zachary J. Slater 2005-09-14 01:19:41 EDT
I'll take a look at this when I have the chance, thanks for reporting it.
Comment 2 Ludwig Nussel 2005-09-17 10:20:30 EDT
well spotted, fixed. thanks! 
Comment 3 Ryan C. Gordon 2007-05-21 11:23:27 EDT
Setting a QA contact on all ioquake3 bugs, even resolved ones. Sorry if you get a flood of email from this, it should only happen once. Apologies for the incovenience.

--ryan.