View Issue Details

IDProjectCategoryView StatusLast Update
0002652FSSCPgameplaypublic2012-07-02 01:21
ReporterMjnMixael Assigned ToValathil  
PrioritynormalSeveritycrashReproducibilityrandom
Status resolvedResolutionfixed 
Product Version3.6.14 RC5 
Target Version3.6.14 
Summary0002652: Bombs on destroyed subsystem causes crash.
DescriptionI've now reliably encountered this on RC6 as well as Trunk.

If a bomb is targetting a subsystem on a ship, and that ship/subsystem is destroyed before the bomb impacts it, it will sometimes try to target that same subsystem, but on a different ship.

So, for example, a bomb is fired. It is targetting turret07 on Ship A. Ship A or it's turret07 is destroyed before the bomb makes impact. The bomb starts looking for a new target and chooses Ship B, but then tries to target turret 07 on Ship B. The problem is that Ship B doesn't have turret 07.
Steps To ReproducePlay a mission with lots of bomb action? It's somewhat random because such specific events need to occur.

I'm trying to find a retail mission where it happens most often.
Additional InformationI once traced through the code with Valathil and Goober when this first happened. That's what showed that the bomb was targetting a subsystem that doesn't exist on a new ship.

It was originally with custom bombs, so I used the flag "no subsystem homing" which solved the crash.

Just recently I encountered it with retail bombs.
TagsNo tags attached.

Activities

iss_mneur

2012-05-20 03:38

developer   ~0013568

What is the correct behaviour in this case?

Should the bomb go dumbfire when its target is destroyed? Should the bomb self destruct? or Should the bomb attempt to lock another target?

MjnMixael

2012-05-20 12:12

manager   ~0013574

My guess is that it really just needs some error checking. If subsystem is not found on the current target, find a new subsystem.

That coupled with if the current target is destroyed, be sure to clear all current targeting data including the subsystem.

iss_mneur

2012-05-20 20:25

developer   ~0013580

I think I have found the cause. What type homing weapon is this, heat or aspect? IIRC retail bombs are all aspect seekers.

MjnMixael

2012-05-20 20:29

manager   ~0013581

Yeah, they are aspect seeking.

iss_mneur

2012-05-20 20:39

developer  

mantis_2652.patch (557 bytes)   
Index: code/weapon/weapons.cpp
===================================================================
--- code/weapon/weapons.cpp	(revision 8806)
+++ code/weapon/weapons.cpp	(working copy)
@@ -4049,8 +4049,8 @@
 		}
 	}
 
-  	// AL 4-13-98: Stop homing on a subsystem if parent ship has changed
-	if (wip->wi_flags & WIF_HOMING_HEAT) {
+  	// Stop homing on a subsystem if parent ship has changed
+	if (wip->wi_flags & WIF_HOMING) {
 		if ( wp->target_sig > 0 ) {
 			if ( wp->homing_object->signature != wp->target_sig ) {
 				wp->homing_subsys = NULL;
mantis_2652.patch (557 bytes)   

iss_mneur

2012-05-20 20:41

developer   ~0013582

Please try with the attached patch. It should make all homing weapons drop their subsystem if the target object changes.

MjnMixael

2012-05-21 04:05

manager  

BombTestCrash.7z (539,669 bytes)

MjnMixael

2012-05-21 04:06

manager   ~0013588

I've uploaded a small modpack. The mission included crashes 80% of the time for me with the same error. I also included the capship torpedos because I haven't tested enough to confirm any bombs other than those torpedos and the Helios trigger the crash (even though it seems quite likely).

iss_mneur

2012-05-21 07:04

developer   ~0013591

I did get an assertion to trigger, hopefully its the same one that you were getting.

 Assert: ship_obj->type == OBJ_SHIP
File: modelread.cpp
Line: 3915

ntdll.dll! ZwWaitForSingleObject + 21 bytes
kernel32.dll! WaitForSingleObjectEx + 67 bytes
kernel32.dll! WaitForSingleObject + 18 bytes
fs2_open_3_6_13d_INF_SSE2.exe! SCP_DumpStack + 354 bytes
fs2_open_3_6_13d_INF_SSE2.exe! WinAssert + 208 bytes
fs2_open_3_6_13d_INF_SSE2.exe! find_submodel_instance_point + 66 bytes
fs2_open_3_6_13d_INF_SSE2.exe! find_submodel_instance_world_point + 47 bytes
fs2_open_3_6_13d_INF_SSE2.exe! get_subsystem_pos + 162 bytes
fs2_open_3_6_13d_INF_SSE2.exe! get_subsystem_world_pos + 47 bytes
fs2_open_3_6_13d_INF_SSE2.exe! weapon_home + 1812 bytes
fs2_open_3_6_13d_INF_SSE2.exe! weapon_process_post + 1527 bytes
fs2_open_3_6_13d_INF_SSE2.exe! obj_move_all_post + 108 bytes
fs2_open_3_6_13d_INF_SSE2.exe! obj_move_all + 367 bytes
fs2_open_3_6_13d_INF_SSE2.exe! game_simulation_frame + 1116 bytes
fs2_open_3_6_13d_INF_SSE2.exe! game_frame + 468 bytes
fs2_open_3_6_13d_INF_SSE2.exe! game_do_frame + 242 bytes
fs2_open_3_6_13d_INF_SSE2.exe! game_do_state + 403 bytes
fs2_open_3_6_13d_INF_SSE2.exe! gameseq_process_events + 237 bytes
fs2_open_3_6_13d_INF_SSE2.exe! game_main + 782 bytes
fs2_open_3_6_13d_INF_SSE2.exe! WinMain + 330 bytes
fs2_open_3_6_13d_INF_SSE2.exe! __tmainCRTStartup + 322 bytes
fs2_open_3_6_13d_INF_SSE2.exe! WinMainCRTStartup + 15 bytes
kernel32.dll! BaseThreadInitThunk + 18 bytes
ntdll.dll! RtlInitializeExceptionChain + 99 bytes
ntdll.dll! RtlInitializeExceptionChain + 54 bytes

What follows are my notes:
 Assertion caused by a Howell missile launched by an Osiris trying to get the position of turret05 of Helios launched by a ship that no longer exists. Neither capital ship has exploded. The Howell was jammed?

The Osiris that launched the Howell has the weapons subsystem of the Intrepid targeted. Has no last targeted subsystem. The Intrepid only has turret05a in its subsystem list.

MjnMixael

2012-05-21 12:43

manager   ~0013597

That's it, yup.

The Howell was launched by an Osiris? Odd, I don't think any of the Osiris have Howell in their loadout...

Howells are launched by the Orion and Aratrums are launched by the Typhon.

Regardless, the mission has no jamming or events of any kind really. Just the capships and bombers showing up and fighting with arrival cues.

iss_mneur

2012-05-21 13:19

developer   ~0013598

Hmm, so the plot thickens.

m_m

2012-06-08 10:21

developer   ~0013637

After debugging the assert I think I found the cause of the problem. Apparently the homing object of the weapon gets corrupted of the homing subsystem is destroyed. Somehow it gets set to another object which may or may not be a ship, if it isn't then the assert pops up but if it isn't then the weapon will home onto the turrets position on another ship.

This can be fixed by adding a homing object signature check before homing onto it to prevent bad things from happening.
With that change in place I haven't encountered any crashes and a weapon that looses the subsystem should continue on the current trajectory but I was unable to observe that.

m_m

2012-06-08 10:21

developer  

mantis2652.patch (7,709 bytes)   
Index: code/hud/hudartillery.cpp
===================================================================
--- code/hud/hudartillery.cpp	(revision 8846)
+++ code/hud/hudartillery.cpp	(working copy)
@@ -297,6 +297,7 @@
 
                         Weapons[Objects[weapon_objnum].instance].team = moveup->sinfo.ssm_team;
                         Weapons[Objects[weapon_objnum].instance].homing_object = moveup->sinfo.target;
+						Weapons[Objects[weapon_objnum].instance].homing_obj_sig = moveup->sinfo.target->signature;
                         Weapons[Objects[weapon_objnum].instance].target_sig = moveup->sinfo.target->signature;
 
 						// this makes this particular missile done
Index: code/network/multimsgs.cpp
===================================================================
--- code/network/multimsgs.cpp	(revision 8846)
+++ code/network/multimsgs.cpp	(working copy)
@@ -7403,6 +7403,7 @@
 	}
 
 	wp->homing_object = homing_object;
+	wp->homing_obj_sig = homing_object->signature;
 	wp->homing_subsys = NULL;
 	wp->target_num = OBJ_INDEX(homing_object);
 	wp->target_sig = homing_object->signature;
Index: code/parse/lua.cpp
===================================================================
--- code/parse/lua.cpp	(revision 8846)
+++ code/parse/lua.cpp	(working copy)
@@ -7910,6 +7910,7 @@
 			if(wp->target_sig != newh->sig)
 			{
 				wp->homing_object = newh->objp;
+				wp->homing_obj_sig = newh->sig;
 				wp->homing_pos = newh->objp->pos;
 				wp->homing_subsys = NULL;
 			}
@@ -7917,6 +7918,7 @@
 		else
 		{
 			wp->homing_object = NULL;
+			wp->homing_obj_sig = -1;
 			wp->homing_pos = vmd_zero_vector;
 			wp->homing_subsys = NULL;
 		}
@@ -7949,12 +7951,14 @@
 		if(v3 != NULL)
 		{
 			wp->homing_object = NULL;
+			wp->homing_obj_sig = -1;
 			wp->homing_subsys = NULL;
 			wp->homing_pos = *v3;
 		}
 		else
 		{
 			wp->homing_object = NULL;
+			wp->homing_obj_sig = -1;
 			wp->homing_subsys = NULL;
 			wp->homing_pos = vmd_zero_vector;
 		}
@@ -7986,6 +7990,7 @@
 			if(wp->target_sig != newh->sig)
 			{
 				wp->homing_object = newh->objp;
+				wp->homing_obj_sig = newh->sig;
 				wp->homing_subsys = newh->ss;
 				get_subsystem_pos(&wp->homing_pos, wp->homing_object, wp->homing_subsys);
 			}
@@ -7993,6 +7998,7 @@
 		else
 		{
 			wp->homing_object = NULL;
+			wp->homing_obj_sig = -1;
 			wp->homing_pos = vmd_zero_vector;
 			wp->homing_subsys = NULL;
 		}
Index: code/weapon/weapon.h
===================================================================
--- code/weapon/weapon.h	(revision 8846)
+++ code/weapon/weapon.h	(working copy)
@@ -158,6 +158,7 @@
 	fix		creation_time;					//	time at which created, stuffed Missiontime
 	int		weapon_flags;					//	bit flags defining behavior, see WF_xxxx
 	object*	homing_object;					//	object this weapon is homing on.
+	int		homing_obj_sig;				// signature of object this weapon is homing on. Used for validating the object
 	ship_subsys*	homing_subsys;			// subsystem this weapon is homing on
 	vec3d	homing_pos;						// world position missile is homing on
 	short		swarm_index;					// index into swarm missile info, -1 if not WIF_SWARM
Index: code/weapon/weapons.cpp
===================================================================
--- code/weapon/weapons.cpp	(revision 8846)
+++ code/weapon/weapons.cpp	(working copy)
@@ -3753,6 +3753,7 @@
 	old_homing_objp = wp->homing_object;
 
 	wp->homing_object = &obj_used_list;
+	wp->homing_obj_sig = -1;
 
 	//	Scan all objects, find a weapon to home on.
 	for ( objp = GET_FIRST(&obj_used_list); objp !=END_OF_LIST(&obj_used_list); objp = GET_NEXT(objp) ) {
@@ -3836,6 +3837,7 @@
 					if (dist < best_dist) {
 						best_dist = dist;
 						wp->homing_object	= objp;
+						wp->homing_obj_sig	= objp->signature;
 						wp->target_sig		= objp->signature;
 						wp->homing_subsys	= target_engines;
 
@@ -3976,6 +3978,7 @@
 		objp = &Objects[sop->objnum];
 		if (objp->signature == sig) {
 			wp->homing_object = objp;
+			wp->homing_obj_sig = objp->signature;
 			wp->target_sig = objp->signature;
 			break;
 		}
@@ -4002,7 +4005,7 @@
 	Assert(obj->instance == num);
 	wp = &Weapons[num];
 	wip = &Weapon_info[wp->weapon_info_index];
-	hobjp = Weapons[num].homing_object;
+	hobjp = wp->homing_object;
 
 	//local ssms home only in stages 1 and 5
 	if ( (wp->lssm_stage==2) || (wp->lssm_stage==3) || (wp->lssm_stage==4))
@@ -4044,6 +4047,7 @@
 		if ( wp->target_sig > 0 ) {
 			if ( wp->homing_object->signature != wp->target_sig ) {
 				wp->homing_object = &obj_used_list;
+				wp->homing_obj_sig = -1;
 				return;
 			}
 		}
@@ -4063,6 +4067,7 @@
 		if (wp->homing_subsys->flags & SSF_MISSILES_IGNORE_IF_DEAD) {
 			if ((wp->homing_subsys->max_hits > 0) && (wp->homing_subsys->current_hits <= 0)) {
 				wp->homing_object = &obj_used_list;
+				wp->homing_obj_sig = -1;
 				return;
 			}
 		}
@@ -4086,6 +4091,7 @@
 		wp->target_sig > 0 &&
 		wp->homing_subsys == NULL) {
 			wp->homing_object = &obj_used_list;
+			wp->homing_obj_sig = -1;
 			return;
 	}
 
@@ -4143,7 +4149,7 @@
 	}
 
 	//	If the object it is homing on is still valid, home some more!
-	if (hobjp != &obj_used_list) {
+	if (hobjp != &obj_used_list && hobjp->signature == wp->homing_obj_sig) {
 		float		old_dot, vel;
 		vec3d	vec_to_goal;
 		vec3d	target_pos;	// position of what the homing missile is seeking
@@ -4155,7 +4161,7 @@
 		//	For now, March 7, 1997, MK, heat seeking homing missiles will be able to home on
 		//	any subsystem.  Probably makes sense for them to only home on certain kinds of subsystems.
 		if ( (wp->homing_subsys != NULL) && !(wip->wi_flags2 & WIF2_NON_SUBSYS_HOMING) ) {
-			get_subsystem_world_pos(hobjp, Weapons[num].homing_subsys, &target_pos);
+			get_subsystem_world_pos(hobjp, wp->homing_subsys, &target_pos);
 			wp->homing_pos = target_pos;	// store the homing position in weapon data
 			Assert( !vm_is_vec_nan(&wp->homing_pos) );
 		} else {
@@ -4740,6 +4746,7 @@
 			wp->nearest_dist = 99999.0f;
 			if ( (wip->wi_flags & WIF_HOMING_ASPECT) && target_is_locked) {
 				wp->homing_object = &Objects[target_objnum];
+				wp->homing_obj_sig = Objects[target_objnum].signature;
 				wp->homing_subsys = target_subsys;
 				weapon_maybe_play_warning(wp);
 			} else if ( (wip->wi_flags & WIF_HOMING_JAVELIN) && target_is_locked) {
@@ -4750,12 +4757,15 @@
 						wp->homing_subsys = ship_get_closest_subsys_in_sight(target_ship, SUBSYSTEM_ENGINE, &Objects[weapon_objnum].pos);
 						if (wp->homing_subsys == NULL) {
 							wp->homing_object = &obj_used_list;
+							wp->homing_obj_sig = -1;
 						} else {
 							wp->homing_object = &Objects[target_objnum];
+							wp->homing_obj_sig = Objects[target_objnum].signature;
 							weapon_maybe_play_warning(wp);
 						}
 				} else {
 					wp->homing_object = &Objects[target_objnum];
+					wp->homing_obj_sig = Objects[target_objnum].signature;
 					wp->homing_subsys = target_subsys;
 					weapon_maybe_play_warning(wp);
 				}
@@ -4764,9 +4774,14 @@
 				//	immediately drop it and try to find one in its view cone.
 				if ((target_objnum != -1) && !(wip->wi_flags2 & WIF2_UNTARGETED_HEAT_SEEKER)) {
 					wp->homing_object = &Objects[target_objnum];
+					wp->homing_obj_sig = Objects[target_objnum].signature;
 					weapon_maybe_play_warning(wp);
-				} else
+				}
+				else
+				{
 					wp->homing_object = &obj_used_list;
+					wp->homing_obj_sig = -1;
+				}
 
 				wp->homing_subsys = target_subsys;
 			}
@@ -4949,6 +4964,7 @@
 	wp->start_pos = *pos;
 	wp->objnum = objnum;
 	wp->homing_object = &obj_used_list;		//	Assume not homing on anything.
+	wp->homing_obj_sig = -1;
 	wp->homing_subsys = NULL;
 	wp->creation_time = Missiontime;
 	wp->group_id = group_id;
mantis2652.patch (7,709 bytes)   

MjnMixael

2012-06-08 14:00

manager   ~0013638

My testing confirms the patch works.

Goober5000

2012-06-09 18:10

administrator   ~0013649

Okay, the patch isn't what needs to be done. It adds a functionality which is redundant with what is already there, which is supposed to already work.

The actual cause of the problem, the code that "corrupts the homing object", isn't addressed in this patch. That code needs to be found in order for the problem to be truly solved.

Goober5000

2012-06-11 03:22

administrator   ~0013654

Fix committed to trunk@8869.

Goober5000

2012-06-11 03:24

administrator   ~0013655

Valathil's research revealed that the cause of the bug was a turret changing its target to another ship without also changing its targeted subsystem.

Zacam

2012-07-02 01:21

administrator   ~0013765

Fix committed to fs2_open_3_6_14@8953.

Related Changesets

fs2open: trunk r8866

2012-06-10 22:40

Goober5000


Ported: N/A

Details Diff
fix some aspects of homing (pun not intended), including hopefully Mantis 0002652 Affected Issues
0002652
mod - /trunk/fs2_open/code/weapon/weapons.cpp Diff File

fs2open: trunk r8869

2012-06-10 23:22

Goober5000


Ported: N/A

Details Diff
Valathil's fix for Mantis 0002652 Affected Issues
0002652
mod - /trunk/fs2_open/code/ai/aiturret.cpp Diff File

fs2open: fs2_open_3_6_14 r8952

2012-07-01 21:21

Zacam


Ported: N/A

Details Diff
Backport: Trunk r8456/8866/8867/8868; Made subsystems contain an objnum reference to their parent ship.
fix some aspects of homing (pun not intended), including hopefully Mantis 0002652
remove the vestiges of free_flight_time, which never worked
remove the unnecessary null sets
Affected Issues
0002652
mod - /branches/fs2_open_3_6_14/code/ship/ship.cpp Diff File
mod - /branches/fs2_open_3_6_14/code/ship/ship.h Diff File
mod - /branches/fs2_open_3_6_14/code/weapon/weapon.h Diff File
mod - /branches/fs2_open_3_6_14/code/weapon/weapons.cpp Diff File

fs2open: fs2_open_3_6_14 r8953

2012-07-01 21:22

Zacam


Ported: N/A

Details Diff
Backport: Trunk r8869; Valathil's fix for Mantis 0002652 Affected Issues
0002652
mod - /branches/fs2_open_3_6_14/code/ai/aiturret.cpp Diff File

Issue History

Date Modified Username Field Change
2012-05-16 16:33 MjnMixael New Issue
2012-05-20 03:38 iss_mneur Note Added: 0013568
2012-05-20 03:38 iss_mneur Status new => feedback
2012-05-20 12:12 MjnMixael Note Added: 0013574
2012-05-20 12:12 MjnMixael Status feedback => new
2012-05-20 20:25 iss_mneur Note Added: 0013580
2012-05-20 20:25 iss_mneur Assigned To => iss_mneur
2012-05-20 20:25 iss_mneur Status new => feedback
2012-05-20 20:25 iss_mneur Target Version => 3.6.14
2012-05-20 20:29 MjnMixael Note Added: 0013581
2012-05-20 20:29 MjnMixael Status feedback => assigned
2012-05-20 20:39 iss_mneur File Added: mantis_2652.patch
2012-05-20 20:41 iss_mneur Note Added: 0013582
2012-05-20 20:41 iss_mneur Status assigned => feedback
2012-05-21 04:05 MjnMixael File Added: BombTestCrash.7z
2012-05-21 04:06 MjnMixael Note Added: 0013588
2012-05-21 04:06 MjnMixael Status feedback => assigned
2012-05-21 07:04 iss_mneur Note Added: 0013591
2012-05-21 07:04 iss_mneur Status assigned => feedback
2012-05-21 12:43 MjnMixael Note Added: 0013597
2012-05-21 12:43 MjnMixael Status feedback => assigned
2012-05-21 13:19 iss_mneur Note Added: 0013598
2012-06-08 10:21 m_m Note Added: 0013637
2012-06-08 10:21 m_m File Added: mantis2652.patch
2012-06-08 14:00 MjnMixael Note Added: 0013638
2012-06-09 18:10 Goober5000 Note Added: 0013649
2012-06-11 02:39 Goober5000 Changeset attached => fs2open trunk r8866
2012-06-11 03:22 Goober5000 Changeset attached => fs2open trunk r8869
2012-06-11 03:22 Goober5000 Note Added: 0013654
2012-06-11 03:22 Goober5000 Status assigned => resolved
2012-06-11 03:22 Goober5000 Resolution open => fixed
2012-06-11 03:23 Goober5000 Assigned To iss_mneur => Valathil
2012-06-11 03:24 Goober5000 Note Added: 0013655
2012-07-02 01:21 Zacam Changeset attached => fs2open fs2_open_3_6_14 r8952
2012-07-02 01:21 Zacam Changeset attached => fs2open fs2_open_3_6_14 r8953
2012-07-02 01:21 Zacam Note Added: 0013765