2021-04-17 15:00 EDT

View Issue Details Jump to Notes ] Related Changesets ]
IDProjectCategoryView StatusLast Update
0002778FSSCPmultiplayerpublic2020-11-01 10:37
Assigned ToFSCyborg 
PriorityurgentSeverityminorReproducibilityhave not tried
Product Version3.6.15 
Target VersionFixed in Version 
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.
Attached Files
  • patch file icon 2778_multimsg.patch (1,111 bytes) 2013-01-13 15:41 -
    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 this guys player num 
    @@ -1595,6 +1600,10 @@
     	// get the skill level setting
    +	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
    patch file icon 2778_multimsg.patch (1,111 bytes) 2013-01-13 15:41 +




niffiwan (developer)

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 (developer)

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


FUBAR-BDHR (developer)

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.


karajorma (administrator)

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 (administrator)

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 (administrator)

Fix committed to trunk@9520.


FUBAR-BDHR (developer)

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 (developer)

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


FSCyborg (developer)

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

+Related Changesets

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