View Issue Details

IDProjectCategoryView StatusLast Update
0002778FSSCPmultiplayerpublic2022-06-10 20:40
ReporterFUBAR-BDHR Assigned ToFSCyborg  
PriorityurgentSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version3.6.15 
Summary0002778: Assert on standalone resulting from divide by 0 caused by game_skill_level being out of range
DescriptionYea that's a mouthful but no idea how to state it better.

Had a standalone crash with an Assert(t_goal < delta_t) from approach() in aicode.cpp. Turs out the value of aa (as well as w_max) was -1.#INF000. This was eventually traced back to a set of divide by 0 due to Ai_info[Ships[objp->instance].ai_index].ai_turn_time_scale on line being -0.0 in ai_turn_towards_vector() line 1160. After some more digging the root of the problem was found in init_aip_from_class_and_profile() where the value was set incorrectly as game_skill_level was 222 (valid range is 0-4).

There are asserts for this all over the code except in 2 key areas: Reading from pilot file and sending/receiving multiplayer packets. The only way I can figure that this could happen is if the client who was the host had a corrupted pilot file with the 222 value and that got sent to the host.

So other then the obvious adding some code that checks the values sent and received and probably verifying after the read from the pilot file (I haven't checked the new pilot code) can you think of anything else that could have caused this or done to fix it?

Also probably should add a check before those divide by 0s.
TagsNo tags attached.

Activities

niffiwan

2013-01-11 01:07

developer   ~0014630

Do you know what version of FSO the client was running? i.e. is it the new or old pilot code that might be at fault?

FUBAR-BDHR

2013-01-11 01:49

developer   ~0014631

Unfortunately as with most standalone issues I don't have any information client side outside of the pilot names.

FUBAR-BDHR

2013-01-12 21:56

developer   ~0014636

Attached patch that should catch this and reset in multimsg. I'll put it up on the standalones for testing next time I update them.

This doesn't address the pilot file or the /0.

FUBAR-BDHR

2013-01-13 20:41

developer  

2778_multimsg.patch (1,111 bytes)   
Index: network/multimsgs.cpp
===================================================================
--- network/multimsgs.cpp	(revision 9500)
+++ network/multimsgs.cpp	(working copy)
@@ -1499,6 +1499,11 @@
 	}
 
 	// add the current skill level setting on the host
+	// sanity check - reset skill level to default before sending if out of range
+	if (Game_skill_level < 0 || Game_skill_level >= NUM_SKILL_LEVELS) {
+		Warning(LOCATION, "Trying to send packet containing invalid skill level %i! Valid range 0 to %i. Resetting to default.", Game_skill_level, NUM_SKILL_LEVELS);
+		Game_skill_level = NUM_SKILL_LEVELS / 2;  
+	}
 	ADD_INT(Game_skill_level);
 
 	// add this guys player num 
@@ -1595,6 +1600,10 @@
 
 	// get the skill level setting
 	GET_INT(Game_skill_level);
+	if (Game_skill_level < 0 || Game_skill_level >= NUM_SKILL_LEVELS) {
+		Warning(LOCATION, "Received packet containing invalid skill level %i! Valid range 0 to %i.  Resetting to default.", Game_skill_level, NUM_SKILL_LEVELS);
+		Game_skill_level = NUM_SKILL_LEVELS / 2;  
+	}
 
 	// get my netplayer number
 	GET_INT(my_player_num);
2778_multimsg.patch (1,111 bytes)   

karajorma

2013-01-24 13:48

administrator   ~0014659

I suspect I've seen this issue in a slightly different form. I have a pilot which always crashes the options screen with an out of range value. Unfortunately I was busy fixing other bugs at the time so I didn't have the chance to figure out what caused it.

karajorma

2013-02-02 04:03

administrator   ~0014679

Well I took a look at it and I'm still not sure where the corruption client side is coming from. I think the patch in addition to patching init_aip_from_class_and_profile() with a sanity check would be a good solution so I'll commit that but leave this open so that I can take a better look at it when I'm better equipped to look at bugs.

karajorma

2013-02-02 04:41

administrator   ~0014680

Fix committed to trunk@9520.

FUBAR-BDHR

2013-03-09 23:02

developer   ~0014760

Interesting I just got the warning for sending a packet from the host on one of the standalones. Skill level was 129. Since the receive packet check didn't trigger it seems like something is going wrong on the standalone itself to cause this issue.

FUBAR-BDHR

2013-05-06 09:21

developer   ~0015037

Just had the Port stadalone go down with this warning so the skill level is still somehow getting corrupted. Runnin r9668

FSCyborg

2020-11-01 15:36

developer   ~0017036

Need to investigate this one before year's end!!

FSCyborg

2022-06-10 20:40

developer   ~0017127

Closing as we have not encountered this is recent multiplayer testing.

Related Changesets

fs2open: trunk r9520

2013-02-02 00:19

karajorma


Ported: N/A

Details Diff
FUBAR's fix for Mantis 2778 (Game_skill_level goes out of range and causes crashes) with some changes by me. Affected Issues
0002778
mod - /trunk/fs2_open/code/ai/aicode.cpp Diff File
mod - /trunk/fs2_open/code/network/multimsgs.cpp Diff File
mod - /trunk/fs2_open/code/playerman/managepilot.cpp Diff File

Issue History

Date Modified Username Field Change
2013-01-10 23:01 FUBAR-BDHR New Issue
2013-01-11 01:07 niffiwan Note Added: 0014630
2013-01-11 01:49 FUBAR-BDHR Note Added: 0014631
2013-01-12 21:54 FUBAR-BDHR File Added: 2778_multimsg.patch
2013-01-12 21:56 FUBAR-BDHR Note Added: 0014636
2013-01-13 20:41 FUBAR-BDHR File Deleted: 2778_multimsg.patch
2013-01-13 20:41 FUBAR-BDHR File Added: 2778_multimsg.patch
2013-01-23 06:54 Echelon9 Status new => code review
2013-01-24 13:48 karajorma Note Added: 0014659
2013-02-02 04:03 karajorma Note Added: 0014679
2013-02-02 04:41 karajorma Changeset attached => fs2open trunk r9520
2013-02-02 04:41 karajorma Note Added: 0014680
2013-02-02 04:41 karajorma Status code review => resolved
2013-02-02 04:41 karajorma Resolution open => fixed
2013-02-02 04:42 karajorma Assigned To => karajorma
2013-02-02 04:42 karajorma Status resolved => assigned
2013-03-09 23:02 FUBAR-BDHR Note Added: 0014760
2013-05-06 09:21 FUBAR-BDHR Note Added: 0015037
2013-12-03 09:43 Echelon9 Category AI => multiplayer
2020-11-01 15:36 FSCyborg Note Added: 0017036
2020-11-01 15:37 FSCyborg Assigned To karajorma => FSCyborg
2020-11-01 15:37 FSCyborg Priority normal => urgent
2022-06-10 20:40 FSCyborg Note Added: 0017127
2022-06-10 20:40 FSCyborg Status assigned => closed