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

Binary module functions using ILuaBase from official interface crash when called from coroutine

Open sohpeach opened this issue 11 years ago • 5 comments

Simple to reproduce, download any ol' binary module that uses the official gmod module base and call a function created from it within a coroutine.

sohpeach avatar Sep 08 '14 19:09 sohpeach

u: This is probably caused by ILuaBase's methods using the wrong lua_State reference when within a coroutine.

Lua interfaces appear to hold a pointer to the global Lua state which is then used by their methods rather than the current thread's Lua state

sohpeach avatar Sep 08 '14 19:09 sohpeach

https://github.com/garrynewman/gmod-module-base/issues/3

neico avatar Sep 08 '14 20:09 neico

One example to this issue is in my thread. Using tmysql4 database from coroutine gives me

[ERROR] gamemodes/w/gamemode/corotest.lua:55: bad argument #1 to 'db_calls' (ţł│UÇ8C♦am files\ste3 expected, got no value)

  1. db_calls - [C]:-1
  2. G - gamemodes/w/gamemode/corotest.lua:55
  3. unknown - lua_run:1

Calling MsgC() in the coroutine supresses the error message, but it is kinda a hack fix.

whisperity avatar Sep 03 '15 22:09 whisperity

This was fixed?

Kefta avatar Jul 31 '18 15:07 Kefta

Was this fixed? I seem to be able to use luasocket functions in coroutines just fine.

CornerPin avatar Feb 22 '20 11:02 CornerPin