Skip to content

[VSCRIPT] Closure serialisation crash #165

@samisalreadytaken

Description

@samisalreadytaken

Describe the bug

Failed serialisation of SQFunctionProto::_literals in VScript VM. SQFunctionProto::Save() returns false for WriteObject(v,up,write,_literals[i]) where it cannot write other than primitive types (string, bool, integer, float).

Literals are compiled values that run the _OP_LOAD, _OP_LOADFLOAT, _OP_LOADINT instructions. And any variables in the const table are compiled in.

This does not necessarily have to crash the game though. Error() fail case is not necessary, and it can be changed to an assert, warning while clearing the saved data.

Steps to reproduce

  1. Place an instance/closure in the const table. Instance type (native or not) does not matter.
getconsttable().INSTANCE <- function(){}
  1. Make a closure that accesses a constant instance
function fn() { INSTANCE }
  1. Save the game (and the closure)

Additional context

Workaround:

local K = INSTANCE;
function fn() { K }

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't workingVScriptMapbase - Involves VScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions