Skip to content

Possible bug in dictionary with asEP_ALLOW_IMPLICIT_HANDLE_TYPES is causing the sub-dict in a dict to be copied by value but opAssign was removed #96

Description

@filipworksdev

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.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions