Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LUAU_ASSERT failure in luaG_getline if called from lua_Alloc #850

Closed
shaggie76 opened this issue Mar 1, 2023 · 0 comments · Fixed by #860
Closed

LUAU_ASSERT failure in luaG_getline if called from lua_Alloc #850

shaggie76 opened this issue Mar 1, 2023 · 0 comments · Fixed by #860
Assignees

Comments

@shaggie76
Copy link

We have a profile mode where we pass a custom allocator that uses lua_getinfo(L, frame, "snl", &in) to get callstacks for where we're generating the most garbage.

Under normal operation this works great however if you enable lua_singlestep and start getting luau_callhook calls it can sometimes crash.

The problem occurs when luaD_checkstack needs to reallocate before L->ci->savedpc has been incremented: the allocator tries to call lua_getinfo which then runs into the LUAU_ASSERT in luaG_getline because pc == -1.

We fixed luau_callhook locally by simply moving the luaD_checkstack down below where savedpc is updated, like this:

    // note: the pc expectations of the hook are matching the general "pc points to next instruction"
    // however, for the hook to be able to continue execution from the same point, this is called with savedpc at the *current* instruction
    if (L->ci->savedpc)
        L->ci->savedpc++;

    luaD_checkstack(L, LUA_MINSTACK); // ensure minimum stack size
    L->ci->top = L->top + LUA_MINSTACK;
    LUAU_ASSERT(L->ci->top <= L->stack_last);

It's a simple fix and hopefully it helps someone else doing similar tricks.

@zeux zeux self-assigned this Mar 2, 2023
andyfriesen added a commit that referenced this issue Mar 10, 2023
* Fix #817 
* Fix #850 
* Optimize math.floor/ceil/round with SSE4.1
    * Results in a ~7-9% speedup on the math-cordic benchmark.
* Optimized table.sort.
* table.sort is now ~4.1x faster (when not using a predicate) and ~2.1x
faster when using a simple predicate. Performance may improve further in
the future.
* Reorganize the memory ownership of builtin type definitions.
* This is a small initial step toward affording parallel typechecking.

The new type solver is coming along nicely. We are working on fixing
crashes and bugs.

A few major changes to native codegen landed this week:
* Fixed lowering of Luau IR mod instruction when first argument is a
constant
* Added VM register data-flow/capture analysis
* Fixed issues with optimizations in unreachable blocks

---------

Co-authored-by: Arseny Kapoulkine <[email protected]>
Co-authored-by: Vyacheslav Egorov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants