From a9ad3d1fc3c97a0dbf8cbe55bf8b3f9d329c98ea Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Wed, 30 Jun 2021 10:19:08 +0300 Subject: [PATCH] - prevent appearance of dangling pointers in corpse queue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A dangling pointer in corpse queue may appear if actor is added to the queue when GC is in propagation state. Enqueued corpse actor remains white, and if it’s destroyed and garbage collected before dequeue, a dangling pointer will be accessed during its removal from the queue. In console, do `summon CorpseSpawner` and `gc now` with the following script loaded. Without a write barrier, it will crash in two seconds. ``` class TestCorpse : Actor { States { Spawn: POSS U 1 A_Die; Death: POSS U 1 A_QueueCorpse; Stop; } } class CorpseSpawner : Actor { override void Tick() { A_SpawnItem("TestCorpse"); } } ``` https://forum.zdoom.org/viewtopic.php?t=69842 --- src/playsim/a_action.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/playsim/a_action.cpp b/src/playsim/a_action.cpp index c5e96adcd..63fca0ece 100644 --- a/src/playsim/a_action.cpp +++ b/src/playsim/a_action.cpp @@ -105,6 +105,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_QueueCorpse) corpsequeue.Delete(0); } corpsequeue.Push(self); + GC::WriteBarrier(self); } return 0; }