forked from ValveSoftware/source-sdk-2013
-
Notifications
You must be signed in to change notification settings - Fork 151
Closed
Labels
BugSomething isn't workingSomething isn't working🐧 LinuxMapbase - Related to LinuxMapbase - Related to Linux
Description
Describe the bug
Static initialisation of ScriptHook_t
variables happens after ScriptHook_t::AddParameter()
is called inside BEGIN_ENT_SCRIPTDESC()
, resetting ScriptHook_t::m_desc::m_Parameters
which breaks scripts that expect parameters.
This is not an issue with non-entity hooks such as OnEntityCreated
.
This can be observed in a debugger. Using PlayerRunCommand
as that is the simplest hook with parameters that doesn't have any prerequisites.
(gdb) watch g_Hook_PlayerRunCommand.m_desc.m_Parameters.m_Size
Hardware watchpoint 3: g_Hook_PlayerRunCommand.m_desc.m_Parameters.m_Size
(gdb) c
Continuing.
Thread 1 "hl2_linux" hit Hardware watchpoint 3: g_Hook_PlayerRunCommand.m_desc.m_Parameters.m_Size
Old value = 0
New value = 1
CUtlVector<int, CUtlMemory<int, int> >::GrowVector (this=0xda558190 <g_Hook_PlayerRunCommand+16>, num=1) at /home/runner/work/source-sdk-2013/source-sdk-2013/sp/src/public/tier1/utlvector.h:698
698 ResetDbgInfo();
(gdb) i s
#0 CUtlVector<int, CUtlMemory<int, int> >::GrowVector (this=0xda558190 <g_Hook_PlayerRunCommand+16>, num=1)
at /home/runner/work/source-sdk-2013/source-sdk-2013/sp/src/public/tier1/utlvector.h:698
#1 0xd9002c0a in CUtlVector<int, CUtlMemory<int, int> >::InsertBefore (
this=0xda558190 <g_Hook_PlayerRunCommand+16>, elem=0, src=@0xffffafbc: 31)
at /home/runner/work/source-sdk-2013/source-sdk-2013/sp/src/public/tier1/utlvector.h:858
#2 0xd9044684 in CUtlVector<int, CUtlMemory<int, int> >::AddToTail (this=0xda558190 <g_Hook_PlayerRunCommand+16>,
src=@0xffffafbc: 31) at /home/runner/work/source-sdk-2013/source-sdk-2013/sp/src/public/tier1/utlvector.h:837
#3 0xd9a4d438 in ScriptHook_t::AddParameter (type=<optimized out>, pszName=<optimized out>,
this=0xda558180 <g_Hook_PlayerRunCommand>)
at /home/runner/work/source-sdk-2013/source-sdk-2013/sp/src/public/vscript/ivscript.h:1899
#4 GetScriptDesc<CBasePlayer> ()
at /home/runner/work/source-sdk-2013/source-sdk-2013/sp/src/game/server/player.cpp:560
#5 0xd96df964 in GetScriptDesc<CHL2_Player> ()
at /home/runner/work/source-sdk-2013/source-sdk-2013/sp/src/game/server/hl2/hl2_player.cpp:613
#6 0xd96e04d3 in __static_initialization_and_destruction_0 (__initialize_p=__initialize_p@entry=1,
__priority=__priority@entry=65535)
at /home/runner/work/source-sdk-2013/source-sdk-2013/sp/src/game/server/hl2/hl2_player.cpp:613
#7 0xd96e0dd1 in _GLOBAL__sub_I_hl2_player.cpp(void) ()
at /home/runner/work/source-sdk-2013/source-sdk-2013/sp/src/game/server/hl2/hl2_player.cpp:5068
(gdb) c
Continuing.
ConVarRef mat_dxlevel doesnt point to an existing ConVar
Thread 1 "hl2_linux" hit Hardware watchpoint 3: g_Hook_PlayerRunCommand.m_desc.m_Parameters.m_Size
Old value = 1
New value = 0
CUtlVector<int, CUtlMemory<int, int> >::CUtlVector (initSize=0, growSize=0, this=0xda558190 <g_Hook_PlayerRunCommand+16>) at /home/runner/work/source-sdk-2013/source-sdk-2013/sp/src/public/tier1/utlvector.h:556
556 ResetDbgInfo();
(gdb) i s
#0 CUtlVector<int, CUtlMemory<int, int> >::CUtlVector (initSize=0, growSize=0,
this=0xda558190 <g_Hook_PlayerRunCommand+16>)
at /home/runner/work/source-sdk-2013/source-sdk-2013/sp/src/public/tier1/utlvector.h:556
#1 ScriptFuncDescriptor_t::ScriptFuncDescriptor_t (this=0xda558180 <g_Hook_PlayerRunCommand>)
at /home/runner/work/source-sdk-2013/source-sdk-2013/sp/src/public/vscript/ivscript.h:251
#2 ScriptHook_t::ScriptHook_t (this=0xda558180 <g_Hook_PlayerRunCommand>)
at /home/runner/work/source-sdk-2013/source-sdk-2013/sp/src/public/vscript/ivscript.h:1909
#3 0xd9a56ee8 in __static_initialization_and_destruction_0 (__initialize_p=__initialize_p@entry=1,
__priority=__priority@entry=65535)
at /home/runner/work/source-sdk-2013/source-sdk-2013/sp/src/game/server/player.cpp:500
#4 0xd9a5738a in _GLOBAL__sub_I_player.cpp(void) ()
at /home/runner/work/source-sdk-2013/source-sdk-2013/sp/src/game/server/player.cpp:10362
Steps to reproduce
To observe in game, create a hook with parameters. Legacy type or not does not matter.
Use FireBullets
to test in MSVC, PlayerRunCommand
works in there.
Hooks.Add( player.GetOrCreatePrivateScriptScope(), "PlayerRunCommand", function( ucmd )
{
}, "" );
player.GetOrCreatePrivateScriptScope().PlayerRunCommand <- function()
{
command;
}
player.GetOrCreatePrivateScriptScope().FireBullets <- function()
{
entity;
}
Metadata
Metadata
Assignees
Labels
BugSomething isn't workingSomething isn't working🐧 LinuxMapbase - Related to LinuxMapbase - Related to Linux