View Issue Details

IDProjectCategoryView StatusLast Update
0002900FSSCPAIpublic2013-07-07 22:57
ReporterEchelon9 Assigned ToEchelon9  
PrioritynormalSeveritymajorReproducibilityN/A
Status resolvedResolutionfixed 
Product Version3.7.0 RC2 
Target Version3.7.0 
Summary0002900: Potential uninitialised AI code structures -- dangerous use of Num_objects
DescriptionRelated to Mantis 2897, the use of Num_objects as an end point of range when walking through the Objects[] array is dangerous while we have a non-compacting garbage collection algorithm.

It is possible that within init_ai_objects(), ships will have uninitialised AI information, particularly where a great many objects have been allocated and free'd.
TagsNo tags attached.

Relationships

related to 0002897 resolvedEchelon9 Heap corruption in dock_evaluate_all_docked_objects() objectdock.cpp 

Activities

Echelon9

2013-07-07 12:26

developer  

mantis-2900-preventative-fix.patch (349 bytes)   
Index: code/ai/aicode.cpp
===================================================================
--- code/ai/aicode.cpp	(revision 9706)
+++ code/ai/aicode.cpp	(working copy)
@@ -14080,7 +14080,7 @@
 {
 	int	i;
 
-	for (i=0; i<Num_objects; i++){
+	for (i=0; i<Highest_object_index; i++){
 		if (Objects[i].type == OBJ_SHIP){
 			init_ai_object(i);
 		}

Echelon9

2013-07-07 12:26

developer   ~0015167

Ready for code review

Goober5000

2013-07-07 22:54

administrator   ~0015171

As before, you would need to use Highest_object_index+1 or the <= operator. However, the funny thing is that that function isn't actually used anywhere. :p

Goober5000

2013-07-07 22:57

administrator   ~0015172

Resolving per commit. I also want to highly commend you for searching the codebase after having determined the cause of 0002897. Any time we solve a bug, it is a good idea to see if similar occurrences of the bug manifest themselves in other locations. Rarely, however, do people look for this. I am awarding you the Gold Star on the forums. :)

Related Changesets

fs2open: trunk r9709

2013-07-07 19:59

Goober5000


Ported: N/A

Details Diff
remove an unused function, per Echelon9's detective work (Mantis 0002900) Affected Issues
0002900
mod - /trunk/fs2_open/code/ai/aicode.cpp Diff File

Issue History

Date Modified Username Field Change
2013-07-07 12:06 Echelon9 New Issue
2013-07-07 12:06 Echelon9 Status new => assigned
2013-07-07 12:06 Echelon9 Assigned To => Echelon9
2013-07-07 12:06 Echelon9 Relationship added related to 0002897
2013-07-07 12:26 Echelon9 File Added: mantis-2900-preventative-fix.patch
2013-07-07 12:26 Echelon9 Note Added: 0015167
2013-07-07 12:26 Echelon9 Assigned To Echelon9 => Goober5000
2013-07-07 12:26 Echelon9 Status assigned => code review
2013-07-07 22:54 Goober5000 Note Added: 0015171
2013-07-07 22:55 Goober5000 Changeset attached => fs2open trunk r9709
2013-07-07 22:57 Goober5000 Note Added: 0015172
2013-07-07 22:57 Goober5000 Assigned To Goober5000 => Echelon9
2013-07-07 22:57 Goober5000 Status code review => resolved
2013-07-07 22:57 Goober5000 Resolution open => fixed