- do not pass TObjPtr<> instances as ScriptUtil::Exec() arguments

There was no read barrier inserted for AActor object while it's a subject of garbage collection
Pointer stored in TObjPtr<> was reinterpreted as void* because of vararg function

https://forum.zdoom.org/viewtopic.php?t=64771
This commit is contained in:
alexey.lysiuk 2019-05-22 17:32:33 +03:00 committed by Rachael Alexanderson
parent f25c16c30d
commit 68ca01096e
2 changed files with 14 additions and 9 deletions

View file

@ -202,6 +202,11 @@ public:
return *this; return *this;
} }
T Get() throw()
{
return GC::ReadBarrier(pp);
}
operator T() throw() operator T() throw()
{ {
return GC::ReadBarrier(pp); return GC::ReadBarrier(pp);

View file

@ -9096,7 +9096,7 @@ scriptwait:
break; break;
case PCD_CLEARINVENTORY: case PCD_CLEARINVENTORY:
ScriptUtil::Exec(NAME_ClearInventory, ScriptUtil::Pointer, activator, ScriptUtil::End); ScriptUtil::Exec(NAME_ClearInventory, ScriptUtil::Pointer, activator.Get(), ScriptUtil::End);
break; break;
case PCD_CLEARACTORINVENTORY: case PCD_CLEARACTORINVENTORY:
@ -9119,7 +9119,7 @@ scriptwait:
case PCD_GIVEINVENTORY: case PCD_GIVEINVENTORY:
{ {
int typeindex = FName(Level->Behaviors.LookupString(STACK(2))).GetIndex(); int typeindex = FName(Level->Behaviors.LookupString(STACK(2))).GetIndex();
ScriptUtil::Exec(NAME_GiveInventory, ScriptUtil::Pointer, activator, ScriptUtil::Int, typeindex, ScriptUtil::Int, STACK(1), ScriptUtil::End); ScriptUtil::Exec(NAME_GiveInventory, ScriptUtil::Pointer, activator.Get(), ScriptUtil::Int, typeindex, ScriptUtil::Int, STACK(1), ScriptUtil::End);
sp -= 2; sp -= 2;
break; break;
} }
@ -9148,7 +9148,7 @@ scriptwait:
case PCD_GIVEINVENTORYDIRECT: case PCD_GIVEINVENTORYDIRECT:
{ {
int typeindex = FName(Level->Behaviors.LookupString(TAGSTR(uallong(pc[0])))).GetIndex(); int typeindex = FName(Level->Behaviors.LookupString(TAGSTR(uallong(pc[0])))).GetIndex();
ScriptUtil::Exec(NAME_GiveInventory, ScriptUtil::Pointer, activator, ScriptUtil::Int, typeindex, ScriptUtil::Int, uallong(pc[1]), ScriptUtil::End); ScriptUtil::Exec(NAME_GiveInventory, ScriptUtil::Pointer, activator.Get(), ScriptUtil::Int, typeindex, ScriptUtil::Int, uallong(pc[1]), ScriptUtil::End);
pc += 2; pc += 2;
break; break;
} }
@ -9156,7 +9156,7 @@ scriptwait:
case PCD_TAKEINVENTORY: case PCD_TAKEINVENTORY:
{ {
int typeindex = FName(Level->Behaviors.LookupString(STACK(2))).GetIndex(); int typeindex = FName(Level->Behaviors.LookupString(STACK(2))).GetIndex();
ScriptUtil::Exec(NAME_TakeInventory, ScriptUtil::Pointer, activator, ScriptUtil::Int, typeindex, ScriptUtil::Int, STACK(1), ScriptUtil::End); ScriptUtil::Exec(NAME_TakeInventory, ScriptUtil::Pointer, activator.Get(), ScriptUtil::Int, typeindex, ScriptUtil::Int, STACK(1), ScriptUtil::End);
sp -= 2; sp -= 2;
break; break;
} }
@ -9185,7 +9185,7 @@ scriptwait:
case PCD_TAKEINVENTORYDIRECT: case PCD_TAKEINVENTORYDIRECT:
{ {
int typeindex = FName(Level->Behaviors.LookupString(TAGSTR(uallong(pc[0])))).GetIndex(); int typeindex = FName(Level->Behaviors.LookupString(TAGSTR(uallong(pc[0])))).GetIndex();
ScriptUtil::Exec(NAME_TakeInventory, ScriptUtil::Pointer, activator, ScriptUtil::Int, typeindex, ScriptUtil::Int, uallong(pc[1]), ScriptUtil::End); ScriptUtil::Exec(NAME_TakeInventory, ScriptUtil::Pointer, activator.Get(), ScriptUtil::Int, typeindex, ScriptUtil::Int, uallong(pc[1]), ScriptUtil::End);
pc += 2; pc += 2;
break; break;
} }
@ -9617,16 +9617,16 @@ scriptwait:
break; break;
case PCD_SETWEAPON: case PCD_SETWEAPON:
STACK(1) = ScriptUtil::Exec(NAME_SetWeapon, ScriptUtil::Pointer, activator, ScriptUtil::Class, GetClassForIndex(STACK(1)), ScriptUtil::End); STACK(1) = ScriptUtil::Exec(NAME_SetWeapon, ScriptUtil::Pointer, activator.Get(), ScriptUtil::Class, GetClassForIndex(STACK(1)), ScriptUtil::End);
break; break;
case PCD_SETMARINEWEAPON: case PCD_SETMARINEWEAPON:
ScriptUtil::Exec(NAME_SetMarineWeapon, ScriptUtil::Pointer, Level, ScriptUtil::Pointer, activator, ScriptUtil::Int, STACK(2), ScriptUtil::Int, STACK(1), ScriptUtil::End); ScriptUtil::Exec(NAME_SetMarineWeapon, ScriptUtil::Pointer, Level, ScriptUtil::Pointer, activator.Get(), ScriptUtil::Int, STACK(2), ScriptUtil::Int, STACK(1), ScriptUtil::End);
sp -= 2; sp -= 2;
break; break;
case PCD_SETMARINESPRITE: case PCD_SETMARINESPRITE:
ScriptUtil::Exec(NAME_SetMarineSprite, ScriptUtil::Pointer, Level, ScriptUtil::Pointer, activator, ScriptUtil::Int, STACK(2), ScriptUtil::Class, GetClassForIndex(STACK(1)), ScriptUtil::End); ScriptUtil::Exec(NAME_SetMarineSprite, ScriptUtil::Pointer, Level, ScriptUtil::Pointer, activator.Get(), ScriptUtil::Int, STACK(2), ScriptUtil::Class, GetClassForIndex(STACK(1)), ScriptUtil::End);
sp -= 2; sp -= 2;
break; break;