openresty / lua-cjson

Lua CJSON is a fast JSON encoding/parsing module for Lua
http://www.kyne.com.au/~mark/software/lua-cjson.php
MIT License
433 stars 118 forks source link

undefined symbol: lua_rotate #57

Closed satscreate closed 4 years ago

satscreate commented 4 years ago

I had done below steps, downloaded lua-cjson-2.1.0.7 from this repo,

make install
mkdir -p /usr/local/lib/lua/5.1
rm -f /usr/local/lib/lua/5.1/cjson.so
cp cjson.so /usr/local/lib/lua/5.1
chmod 755 /usr/local/lib/lua/5.1/cjson.so

Then, sudo systemctl restart nginx.service

Error:

2020/02/19 06:59:52 [error] 29524#29524: *1 lua entry thread aborted: runtime error: error loading module 'cjson' from file '/usr/local/lib/lua/5.1/cjson.so':
        /usr/local/lib/lua/5.1/cjson.so: undefined symbol: lua_rotate
stack traceback:
coroutine 0:
        [C]: in function 'require'

What am i missing!!!!

agentzh commented 4 years ago

Are you sure? This repo has no "lua_rotate" call at all on the master branch. You can try grepping the word "rotate" yourself.

agentzh commented 4 years ago

And there's no lua_rorate symbol in LuaJIT. It seems to be part of the Lua 5.3 ABI.

satscreate commented 4 years ago

Yes am sure about it. it gives this error when i try to start nginx with below setup,

access_by_lua '
         local opts = {
           redirect_uri_path = "/redirect_uri",
           accept_none_alg = true,
           discovery = "http://www.example.com:8080/auth/realms/NGINX/.well-known/openid-configuration",
           client_id = "nginx",
           client_secret = "62d3b835-e3d1-4cec-a2f2-612f496bc6c3",
           redirect_uri_scheme = "http",
           logout_path = "/logout",
           redirect_after_logout_uri = "http://www.example.com:8080/auth/realms/NGINX/protocol/openid-connect/logout?redirect_uri=http://www.example.com/",
           redirect_after_logout_with_id_token_hint = false,
           session_contents = {id_token=true}
         }
         -- call introspect for OAuth 2.0 Bearer Access Token validation
         local res, err = require("resty.openidc").authenticate(opts)
         if err then
           ngx.status = 403
           ngx.say(err)
           ngx.exit(ngx.HTTP_FORBIDDEN)
         end
      ';
      # I disabled caching so the browser won't cache the site.
      expires           0;
      add_header        Cache-Control private;
      location / {
      }

With this setup this seems error ed out with this exception

2020/02/19 09:04:16 [error] 17679#17679: *1 lua entry thread aborted: runtime error: error loading module 'cjson' from file '/usr/local/lib/lua/5.1/cjson.so':
        /usr/local/lib/lua/5.1/cjson.so: undefined symbol: lua_rotate
stack traceback:
coroutine 0:
        [C]: in function 'require'
        access_by_lua(sample.conf:40):15: in function <access_by_lua(sample.conf:40):1>,
agentzh commented 4 years ago

@satscreate Your cjson.so was compiled against the Lua 5.3 interpreter's header files I believe. You should try our OpenResty instead to avoid such things (lua-cjson is part of the OpenResty build):

https://openresty.org/en/download.html

satscreate commented 4 years ago

@satscreate Your cjson.so was compiled against the Lua 5.3 interpreter's header files I believe. You should try our OpenResty instead to avoid such things (lua-cjson is part of the OpenResty build):

https://openresty.org/en/download.html

How can i compile against this version or lower version,

[root@sample ~]# lua -v
Lua 5.3.3  Copyright (C) 1994-2016 Lua.org, PUC-Rio

And below way am actually adding lua path in nginx.conf: lua_package_path "/usr/local/lib/lua/?.lua;;";

Since am interested in compiling modules by own and apply on top if nginx so. can you please help me on steps to resolve the same without actual openresty installation. because openresty itself comes with own nginx version which am not going to utilize so.

agentzh commented 4 years ago

@satscreate I said the easiest way is to use OpenResty directly. If you really want to compile lua-cjson yourself, you'll have to fiddle with the Makefile variables to point the header file path to OpenResty's LuaJIT header file directory.

agentzh commented 4 years ago

The biggest point of OpenResty is to avoid such things in the first place.