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

Fix crashing from calling loadlib more than once on the same dll #5

Merged
merged 2 commits into from
Jun 28, 2019

Conversation

SpiralP
Copy link
Contributor

@SpiralP SpiralP commented Jun 19, 2019

I ran into this bug from trying to require("cqueues") which runs

	local core = require"_cqueues"
	local errno = require"_cqueues.errno"

where _cqueues is _cqueues.so

The require() here will call

loadlib("_cqueues.so", "luaopen__cqueues", false)
then
loadlib("_cqueues.so", "luaopen__cqueues_errno", false) <-- crash here

and proceed to crash

@SpiralP
Copy link
Contributor Author

SpiralP commented Jun 19, 2019

here's me testing on server # 2

aowl table loadlib("_cqueues.so", "luaopen__cqueues", false)
function:([C])
aowl table loadlib("_cqueues.so", "luaopen__cqueues_errno", false)
function:([C])
aowl table loadlib("_openssl.so", "luaopen__openssl", false)
function:([C])
aowl table loadlib("_openssl.so", "luaopen__openssl", false)
function:([C])

previously

aowl table loadlib("_openssl.so", "luaopen__openssl", false)
function:([C])
aowl table loadlib("_openssl.so", "luaopen__openssl", false)


CRASH: Signal=11,1

TIME:1560906484
Fault=0x215 Caller=0xf7fdf42a
REG: gs 63 fs: 0 es: 2b ds: 2b edi: 0 esi: df78f1d0 ebp: 0 esp: ffff9170 ebx: f7ffd000 edx: 79be535b ecx: ffff923c
REG: eax: 211 trap: 14 err: 4 eip: f7fdf42a cs: 23 flag: 210282 sp: ffff9170 ss: 2b cr2: 215

TRACE
 1 0xe24598ef 0xe247ce80 ERROR_SIGNAL_HANDLER_FUNC(int, siginfo_t*, void*) +0x6ff               @ gmsv_segfault_linux.dll +0x68ef
 2 0xf7fd5080 0xe247d1c0 ? +0x6ff (SF)          @ linux-gate.so.1 +0x1080
 3 0xf7fdf42a 0xffff9170 _dl_rtld_di_serinfo +0x3ca             @ ld-linux.so.2 +0x942a
 4 0xf7fdff9b 0xffff91e0 _dl_rtld_di_serinfo +0xf3b             @ ld-linux.so.2 +0x9f9b
 5 0xf7e9b5bc 0xffff9280 __libc_dlclose +0x10c                  @ libc.so.6 +0x1345bc
 6 0xf7f62de1 0xffff9310 dlclose +0x71                  @ libdl.so.2 +0xde1
 7 0xf7e9bc20 0xffff9330 _dl_catch_exception +0x90              @ libc.so.6 +0x134c20
 8 0xf7e9bcd0 0xffff9420 _dl_catch_error +0x30                  @ libc.so.6 +0x134cd0
 9 0xf7f633c1 0xffff9450 dlerror +0x2d1                 @ libdl.so.2 +0x13c1
10 0xf7f62e63 0xffff9480 dlsym +0x73            @ libdl.so.2 +0xe63
11 0xdf954b6c 0xffff94c0 FindFunction(void*, char const*) +0x1c                 @ gmsv_require2.core_linux.dll +0x5cb6c
12 0xdf955968 0xffff94e0 loadlib__Imp(GarrysMod::Lua::ILuaBase*) +0x518                 @ gmsv_require2.core_linux.dll +0x5d968
13 0xdf955be9 0xffff9540 loadlib(lua_State*) +0x29              @ gmsv_require2.core_linux.dll +0x5dbe9
14 0xf236dd19 0xffff9560 lj_BC_FUNCC +0x32              @ lua_shared_srv.so +0x5ad19
15 0xf23611f8 0xffff9590 lua_pcall +0x48                @ lua_shared_srv.so +0x4e1f8
16 0xf232c38c 0xffff95b0 CLuaInterface::PCall(int, int, int) +0x2c              @ lua_shared_srv.so +0x1938c
17 0xf232f676 0xffff95e0 CLuaInterface::CallFunctionProtected(int, int, bool) +0x76             @ lua_shared_srv.so +0x1c676
18 0xf232d56c 0xffff9620 CLuaInterface::CallInternalNoReturns(int) +0x2c                @ lua_shared_srv.so +0x1a56c
19 0xf2c8cb3f 0xffff9650 LuaConCommand(CCommand const&) +0x1af                  @ server_srv.so +0x69cb3f
20 0xf6d3fe8f 0xffff96c0 Cmd_ExecuteCommand(CCommand const&, cmd_source_t, int) +0x41f                  @ engine_srv.so +0xe0e8f
21 0xf6d3fffc 0xffff9700 Cbuf_Execute() +0xdc           @ engine_srv.so +0xe0ffc
END:Host_RunFrame

LUA
| 0     [C]:-1: loadlib
| 1     ??[NULL Entity]:1: ?
| 2     [C]:-1: LUADEV_EXECUTE_FUNCTION
| 3     lua/luadev/luadev_sh.lua:445: callback
| 4     lua/autorun/server/luadev_chatcmds.lua:12: ?
| 5     [C]:-1: xpcall
END:maxdepth

STACK:7: '_openssl.so', 'luaopen__openssl', B0, '_openssl.so', '/home/srcds/srcds2/garrysmod/lua/libraries/_openssl.so', 'LOADLIB: _openssl.so', <UserData>.

@danielga danielga self-assigned this Jun 21, 2019
@danielga danielga added the bug label Jun 21, 2019
@danielga danielga self-requested a review June 21, 2019 17:21
Copy link
Owner

@danielga danielga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request looks good. After that requested change, I'll merge it.

@danielga danielga merged commit c8bb68d into danielga:master Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants