I am adding AngelScript into my project custom game engine but i made @ handle implicit via asEP_ALLOW_IMPLICIT_HANDLE_TYPES option
The problem was that dictionary was losing it's data. I investigated with help of AI because I am not familiar with the code and I found potentially a bug in AngelScript.
Initially I thought that was data was lost but having investigated more I found the issue was dictionaries were throwing an exception. Lines like st["vars"] = vars or states[id] = st (writing one dictionary into another) were failing at runtime with Cannot do value assignment.
The issue appears to be something like this:
- Under
asEP_ALLOW_IMPLICIT_HANDLE_TYPES (the @-removal migration), a dictionary vars arg is an implicit handle but gets passed to CScriptDictValue::Set with the VALUE typeId (no asTYPEID_OBJHANDLE flag).
Set saw "not a handle" → took the value-copy branch (CreateScriptObjectCopy).
- But the migration had removed the dictionary's
opAssign, so a value-copy is impossible → the runtime threw Cannot do value assignment.
- From outside looked like data is broke or missing
The fix was having to change the
scriptdictionary addon: in CScriptDictValue::Set, when the object type has asOBJ_IMPLICIT_HANDLE, store the handle (not a value copy) — m_valueObj = value; AddRefScriptObject(...). (Note: value is the object pointer here; dereferencing it AV'd 0xC0000005.)
I am adding AngelScript into my project custom game engine but i made @ handle implicit via asEP_ALLOW_IMPLICIT_HANDLE_TYPES option
The problem was that dictionary was losing it's data. I investigated with help of AI because I am not familiar with the code and I found potentially a bug in AngelScript.
Initially I thought that was data was lost but having investigated more I found the issue was dictionaries were throwing an exception. Lines like
st["vars"] = varsorstates[id] = st(writing onedictionaryinto another) were failing at runtime withCannot do value assignment.The issue appears to be something like this:
asEP_ALLOW_IMPLICIT_HANDLE_TYPES(the@-removal migration), adictionary varsarg is an implicit handle but gets passed toCScriptDictValue::Setwith the VALUE typeId (noasTYPEID_OBJHANDLEflag).Setsaw "not a handle" → took the value-copy branch (CreateScriptObjectCopy).opAssign, so a value-copy is impossible → the runtime threwCannot do value assignment.The fix was having to change the
scriptdictionaryaddon: inCScriptDictValue::Set, when the object type hasasOBJ_IMPLICIT_HANDLE, store the handle (not a value copy) —m_valueObj = value; AddRefScriptObject(...). (Note:valueis the object pointer here; dereferencing it AV'd0xC0000005.)