Skip to content

"Invalid script state" when rezzing a script with a big and empty stack #79

@Suzanna-Linn

Description

@Suzanna-Linn

With this:

local tab = table.create(2500, true)

local co = coroutine.create(function()
    tab = { unpack( tab, 2, 2500 ) }
    coroutine.yield()
end)

coroutine.resume(co)
tab = nil

LLTimers:every(86400, function()
    print(co)
end)

or the same but with LLEvents instead of LLTimers:

local tab = table.create(2500, true)

local co = coroutine.create(function()
    tab = { unpack( tab, 2, 2500 ) }
    coroutine.yield()
end)

coroutine.resume(co)
tab = nil

LLEvents:on("touch_start", function()
    print(co)
end)

To reproduce:

  • make a new box
  • add the script
  • save
  • take to inventory
  • rezz -- > Script run-time error / Invalid Script State

The idea is to make a small script with a coroutine that have a big stack that is currently empty. It also needs a timer or an event with the coroutine.

I was trying to crash this line, or perhaps I have found something else by chance:

VALIDATE_SIZE(stack_size);


Other unrelated lines that could have an issue, but I don't know how to test it:

Are min and max exchanged?

pc_offset = std::min(0, std::max(real_pc, lcl->l.p->sizecode - 1));

Should pop 1 in the last line?

slua/VM/src/ares.cpp

Lines 3131 to 3136 in f629edc

if (lua_rawequal(L, -2, -1)) {
// They're the same table - skip registering this, let global scan handle it
lua_pop(L, 2);
continue;
}
lua_pop(L, 2); // Pop global_module and base_globals

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions