Bug #2505
openServer crash on save after /remove during a diplomacy meeting
0%
Description
Meet with another nation, and while the meeting is open, /remove that player (after game start, that takes admin level, or the server console). The meeting stays open; the next save reads the freed player and the server crashes.
In the client the meeting tab stays open too, and pressing "Cancel meeting" or Accept reads the freed player there.
Under ASan:
heap-use-after-free READ in treaty_save savegame3.c:7989
<- treaties_iterate <- sg_save_treaties <- savegame3_save_real <- save_command
freed by player_destroy <- server_remove_player plrhand.c:2040
client: heap-use-after-free READ in player_number
<- diplomacy_response diplodlg.c:752
freed by player_destroy <- handle_player_remove
server_remove_player() never cancels the player's meetings, so the treaty keeps pointers to the freed player. kill_player() and the AI toggles already call cancel_all_meetings().
Attached patch calls cancel_all_meetings() in server_remove_player() before the player's connections are detached, so both sides are told and the client closes its tab the normal way. A treaty only points to its two players (and clauses to one of them), so nothing else is left behind.
Applies to main, S3_3 and S3_2.
Related to #383, a different stale reference left by server_remove_player()
Files
Updated by Sweet Tea Dorminy 4 days ago
Updated by Marko Lindqvist 4 days ago
Sweet Tea Dorminy wrote:
/remove that player
Have you tested also player removal ("Destroy") functionality in the editor mode?
Updated by Marko Lindqvist 4 days ago
- Status changed from New to In Review
- Assignee set to Marko Lindqvist
- Target version set to 3.2.8