Lua unresolved symbol: receiving an error loading a lua module lrexlib.
Description:
I'm trying to use the lua filter (fully understanding its experimental). One of our users requires the use of libpcre but we're running into issues including the lrexlib lua library
error:
[2017-12-21 20:15:15.243][32732][error][lua] source/common/http/filter/lua/lua_filter.cc:485] script log: error loading module 'rex_pcre' from file '/usr/local/lib/lua/5.1/rex_pcre.so':
/usr/local/lib/lua/5.1/rex_pcre.so: undefined symbol: lua_checkstack
The script in question could be summarized as
local rex = require "rex_pcre"
match = rex.match(referrerHeader, '^\\/search\\?.*category=.*')
Hmm. I'm going to guess this has something to do with either LuaJIT or the fact that we statically link LuaJIT, but I'm not really sure. I'm not going to have time to look into this for a while, so will mark this help wanted in case any Lua experts have an idea.
Your are using the lrexlib external library inside your lua script
http://rrthomas.github.io/lrexlib/manual.html
It is common for people to use this to do some string matching.
I am still trying to play with envoy lua but I think at this point it simply look for external library from a fixed location. So I guess you can simply compile lrexlib and make sure the generated shared object library is in /usr/local/lib/lua/5.1/ and try again.
Hello,
So I was able to fix this by adding -Wl,-E to the list of linker options. I do not have a good explanation of why this works only that it does work in my case 馃
Sorry i misunderstood the original problem a little.
The reason for the need of the above linker options (export-dynamic) are also somewhat explained here, too -
https://github.com/zdevito/terra/issues/6
Yeah, this has to do with static linking and the fact that the Envoy binary needs to export the symbols that the SOs need. @taion809 can you potentially do a doc update? https://github.com/envoyproxy/data-plane-api/blob/master/docs/root/configuration/http_filters/lua_filter.rst (Maybe an attention at the top). It would probably be worth it to make the link option settable via a bazel option and document that also.
@mattklein123 sure, could you assign it to me and ill look at it next week?
@taion809 done, thank you!
This is fixed.
@taion809 You are my hero.
Just ran into the same issue, and apparently -Wl,-E did the trick.
Most helpful comment
Hello,
So I was able to fix this by adding
-Wl,-Eto the list of linker options. I do not have a good explanation of why this works only that it does work in my case 馃