Skip to content

Stop the lua panics from crashing the game completely #4894

@artemking4

Description

@artemking4

Currently, any lua panics cause a engine error and close your game completely.
It would be alot better to make client state lua panics close the state and disconnect the user instead.
When developing modules, this can be really annoying to rejoin the game every time you need to test your client module.

Activity

thegrb93

thegrb93 commented on Apr 9, 2021

@thegrb93

pcall so it doesn't lua panic.

artemking4

artemking4 commented on Apr 10, 2021

@artemking4
Author

What if its not you who is causing the lua panic? What if it is some lua? I have seen people do that, for an example you can cause a 'gamemode is not a table' lua panic pretty easily. You can also create custom panics.

robotboy655

robotboy655 commented on Apr 10, 2021

@robotboy655
Contributor

gamemode is not a table

A lot of stuff like that was already gotten rid of in recent updates (weapons, sents), but the primary concern here is still that the game will just crash in dozen other spots like when I attempted to get rid of the gamemode one.

Also a lot of Lua Panics end users get are the "out of memory" panics, and I'd rather have them see a message saying out of memory rather than just crash in some other random part of the engine that doesn't handle OOM.

artemking4

artemking4 commented on Apr 12, 2021

@artemking4
Author

You can still just disconnect the user from the server and close the client state.

For the OOM issue, you can do the same, closing the state (and calling the gc if it doesnt do it by itself) would free up some memory. You can after that test if the issue is gone: allocate the same memory and immeditately delete it, if you can not - fine, just crash then. Otherwise we can assume the issue is gone.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @robotboy655@thegrb93@artemking4

        Issue actions