garrysmod-issues icon indicating copy to clipboard operation
garrysmod-issues copied to clipboard

Client won't report all details in errors

Open RaphaelIT7 opened this issue 1 year ago • 5 comments

Details

When you have a client error in a callback, like in a timer,
It only networks the error, but it will miss stuff like Timer Failed! [Simple][@LuaCmd (line 1)]

This can cause in some cases for errors to be just like this one [ERROR] attempt to call a userdata value which makes it really hard to fix those.
Maybe throw another error with the timer message.
But at least let OnLuaError know that it was a callback that had an error, and maybe also let the server somehow know.

Steps to reproduce

  1. Start a Server
  2. Run lua_run_cl timer.Simple(1, function() error("a") end)
  3. See that this print is only visible to the client -> Timer Failed! [Simple][@LuaCmd (line 1)]

RaphaelIT7 avatar Sep 04 '24 16:09 RaphaelIT7

image Not sure I follow.

robotboy655 avatar Sep 05 '24 11:09 robotboy655

Oh you mean the fact that Timer Failed! only appears on the client? Well that's normal given that it's not an error.

robotboy655 avatar Sep 05 '24 11:09 robotboy655

Yes. I would expect it to be a part of the error message since there are cases where there is no stack and just the error and when the client doesn't report it with the timer error message, it can be a pain to figure out / be basically impossible. There are probably more cases where this could happen like file.AsyncRead, NWVarProxy which all have callbacks.

Edit: I don't know how these cases with no stack happen, but they do somehow

RaphaelIT7 avatar Sep 05 '24 12:09 RaphaelIT7

The correct stack trace does get included in the error that gets networked: image

I don't know in what scenario there would be no stack trace, but I don't think making this message an error would really help since there would be no stack info either I would image?

Regardless, changing this wouldn't help with other callbacks as you say, since those do not print their own messages on error typically.

This feels like an issue with Lua itself perhaps? Or somehow the code that handles reading the stack trace? Without a reproducible case I don't think there's much I can really do here.

robotboy655 avatar Sep 05 '24 12:09 robotboy655

Just remembered that months ago I showed someone something like it. This is one of the ways to have an error with a broken stack: lua_run debug.setmetatable(newproxy(), FindMetaTable("VMatrix")) As soon as Lua's gc kicks in(or with collectgarbage()), you can get

  • [ERROR] bad argument #1 to '__concat' (VMatrix expected, got userdata) Happens with this local a="a" for k=1, 10000 do a=a.."a" end
    Raise it to 100000 and it will cause a crash
  • [ERROR] bad argument #1 to '?' (VMatrix expected, got userdata) Happens when using collectgarbage()

    It's something old which I just dug out of a chat, and it may not be related to timer callbacks, but it can reproduce the stack issue.

Edit: in that case we don't even use a function, so it could be hard or probably impossible to solve that. Wouldn't it be possible to add an additional stack entry when an error in callbacks or gc happens? But when I'll be home in like ~4 hours, I can try to find a way to reproduce it

Edit 2: It doesn't seem like there is a way to reproduce it, but it's definitely something that happens. Example from clientside_errors.txt (Yes it's the same client, but apparently he had it multiple times?):

[UserName]|18|[SteamID]

[ERROR] attempt to call a number value



[UserName]|18|[SteamID]

[ERROR] attempt to call a table value



[UserName]|18|[SteamID]

[ERROR] attempt to call a table value



[UserName]|18|[SteamID]

[ERROR] attempt to call a table value



[UserName]|18|[SteamID]

[ERROR] attempt to call a table value

RaphaelIT7 avatar Sep 05 '24 12:09 RaphaelIT7