danielga / gm_luaerror

A module for Garry's Mod that adds hooks for obtaining errors that happen on the client and server (if activated on server, it also pushes errors from clients).
https://github.com/danielga/gm_luaerror
Other
54 stars 8 forks source link

unable to obtain AdvancedLuaErrorReporter #45

Closed wrefgtzweve closed 1 year ago

wrefgtzweve commented 2 years ago

Getting this error when i require luaerror on 32 bit dedicated linux server unable to obtain AdvancedLuaErrorReporter happens on 1.5.8,1.5.7, 1.5.6

danielga commented 1 year ago

You said you're running the module on a 32 bits dedicated Linux server. Is this on the main or x86-64 branch of Garry's Mod?

wrefgtzweve commented 1 year ago
> version
Protocol version 24
Exe version 2022.06.08 (garrysmod)
Exe build: 19:30:41 Jun  1 2022 (8607) (4000)
GMod version 2022.06.10, branch: unknown
Linux 32bit Dedicated Server

Main, i require it on autorun

danielga commented 1 year ago

I am unable to reproduce the issue on a clean, main branch, dedicated Linux server.

version Protocol version 24 Exe version 2022.06.08 (garrysmod) Exe build: 19:30:41 Jun 1 2022 (8607) (4000) GMod version 2022.06.10, branch: unknown Linux 32bit Dedicated Server lua_run PrintTable(luaerror) > PrintTable(luaerror)... EnableClientDetour = function: 0xf1b0d748 EnableCompiletimeDetour = function: 0xf1b0d7d8 EnableRuntimeDetour = function: 0xf1b0d790 FindWorkshopAddonFileOwner = function: 0xf1b0d7f8 Version = luaerror 1.5.8 VersionNum = 10508

Do you use other modules? If yes, can you list them please? Maybe providing links to them or their source code would help too.

wrefgtzweve commented 1 year ago

We use https://github.com/storm37000/gmsv_antifreeze https://github.com/FredyH/GWSockets https://github.com/danielga/gmsv_serversecure https://github.com/WilliamVenner/gmsv_reqwest https://github.com/FredyH/MySQLOO and luaerror of course

danielga commented 1 year ago

After looking at luaerror's source code and what causes that error to appear, I've got an interesting test for you.

LUA->ReferencePush( 1 );
if( !LUA->IsType( -1, GarrysMod::Lua::Type::FUNCTION ) )
    LUA->ThrowError( "reference to AdvancedLuaErrorReporter is invalid" );

First, this gets the first element of Lua's registry. In this case, we're checking if it's a function and it is, because the error is not that one.

AdvancedLuaErrorReporter = LUA->GetCFunction( -1 );
if( AdvancedLuaErrorReporter == nullptr )
    LUA->ThrowError( "unable to obtain AdvancedLuaErrorReporter" );

Secondly, we try to get a pointer to that function. Now, if it was the original one, this would've worked. Unfortunately, since the error you got was this one, it means it's NOT a C function.

Can you try print(debug.getregistry()[1]) and PrintTable(debug.getinfo(debug.getregistry()[1], "flnSu")) before you require luaerror? I think that'll tell us it's not the original function.

wrefgtzweve commented 1 year ago
lua_run print(debug.getregistry()[1])
> print(debug.getregistry()[1])...
function: 0xf1bf91b8
lua_run PrintTable(debug.getinfo(debug.getregistry()[1], "flnSu"))
> PrintTable(debug.getinfo(debug.getregistry()[1], "flnSu"))...
currentline     =       -1
func    =       function: 0xf1bf91b8
isvararg        =       true
lastlinedefined =       221
linedefined     =       211
namewhat        =
nparams =       0
nups    =       1
short_src       =       lua/autorun/advr_error_api.lua
source  =       @lua/autorun/advr_error_api.lua
what    =       Lua

Hmmm file originates from https://steamcommunity.com/sharedfiles/filedetails/?id=2853674790 which is used in https://github.com/Xalalau/gerror https://gerror.xalalau.com/

danielga commented 1 year ago

Can you give this build a go? I had to sigscan for the original function and detour that instead...

wrefgtzweve commented 1 year ago
lua_run print(debug.getregistry()[1])
> print(debug.getregistry()[1])...
function: 0xf1c57348
lua_run debug.getregistry()[1] = function() end
> debug.getregistry()[1] = function() end...
lua_run print(debug.getregistry()[1])
> print(debug.getregistry()[1])...
function: 0xeaa616a8
lua_run require("luaerror")
> require("luaerror")...
lua_run print(luaerror)
> print(luaerror)...
table: 0xeaa619f0
danielga commented 1 year ago

Seems like it's working, closing the issue.

brandonsturgeon commented 1 year ago

I maintain a project that relies on this tool - I hear from a number of users that they still have this problem on the latest release.

What info could I gather from them to help debug the issue?

danielga commented 1 year ago

Do you gather analytics, like luaerror version? Because that would be really helpful to know whether they have it updated or not. If yes, it might've broken again, and I'd appreciate if you opened a new issue.

brandonsturgeon commented 1 year ago

Noted. Thanks 👍

CheezusChrust commented 1 year ago

I posted a new issue regarding this about 3 weeks ago - https://github.com/danielga/gm_luaerror/issues/47 I'm running on the latest GMod update and latest version of luaerror