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

_G write guard whines about zlib being global and could cause race conditions #48

Open
Raw1mage opened this issue Aug 1, 2019 · 5 comments

Comments

@Raw1mage
Copy link

Raw1mage commented Aug 1, 2019

when I do this

    local zlib = require ("zlib")

nginx error log would show:
[warn] 30914#30914: *24397 [lua] _G write guard:12: writing a global lua variable ('zlib') which may lead to race conditions between concurrent requests, so prefer the use of 'local' variables
stack traceback:
[C]: at 0x7f165255b755
[C]: in function 'require'

any light ?

@brimworks
Copy link
Owner

Maybe because we use the old luaL_register function when we should be using luaL_setfuncs?

https://github.com/brimworks/lua-zlib/blob/master/lua_zlib.c#L1263

Feel free to issue a pull request if this change fixes your issue.

Thanks!
-Brian

@davidguerreroprezi
Copy link

I had the same issue and could fix it by replacing the luaL_register with this:

lua_newtable(L);
luaL_setfuncs(L, zlib_functions, 0);

It works when importing from openresty (luajit), but not from standalone Lua 5.1

@brimworks
Copy link
Owner

Perhaps a little "macro magic" could solve this problem? Pull requests are welcomed :).

@a652
Copy link

a652 commented May 27, 2020

I had the same issue with lua-zlib-1.2

@howiezhao
Copy link

If you use OpenResty, maybe can refer to this openresty/openresty#510 as a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants