Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

224
Visualizações
Lua inside shared library conflict with Nginx or websocketpp?

I'm using a red pitaya board (version 125-14) where user apps (compiled to .so file) are loaded dynamically in nginx upon web request. More specifically, Nginx starts a websocket server and the app is loaded to process websocket data. Recently I'd like to integrate lua inside my app, but a basic lua_pcall leads to segfault.

    lua_State* L = luaL_newstate();
    luaL_openlibs(L);
    // execute script
    const char lua_script[] = "a=1;";
    int load_stat = luaL_loadbuffer(L, lua_script, strlen(lua_script), lua_script);
    lua_pcall(L, 0, 0, 0);
    // cleanup
    lua_close(L);

So I added -g when compiling Lua and use gdb to see if there is more infomation. That's what I got with backtrace:

Thread 2 "nginx" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb3796440 (LWP 27528)]
0xb382fb5a in luaD_precall (L=0xb2f771c0, func=0xfffffff0, nresults=0) at ldo.c:511
511       switch (ttypetag(s2v(func))) {
(gdb) backtrace
#0  0xb382fb5a in luaD_precall (L=0xb2f771c0, func=0xfffffff0, nresults=0) at ldo.c:511
#1  0xb382fdd2 in ccall (L=0xb2f771c0, func=0xfffffff0, nResults=0, inc=65537) at ldo.c:575
#2  0xb382fe36 in luaD_callnoyield (L=0xb2f771c0, func=0xfffffff0, nResults=0) at ldo.c:595
#3  0xb382cc5a in f_call (L=0xb2f771c0, ud=0xb3795304) at lapi.c:1031
#4  0xb382f17e in luaD_rawrunprotected (L=0xb2f771c0, f=0xb382cc3d <f_call>, ud=0xb3795304)
    at ldo.c:144
#5  0xb38303e4 in luaD_pcall (L=0xb2f771c0, func=0xb382cc3d <f_call>, u=0xb3795304,
    old_top=1292402216, ef=0) at ldo.c:892
#6  0xb382cce4 in lua_pcallk (L=0xb2f771c0, nargs=0, nresults=0, errfunc=0, ctx=0, k=0x0)
    at lapi.c:1057
#7  0xb3821870 in setupLUA ()
    at /root/.vs/CMakeProject1/657aa1fb-2594-4c6c-95fc-066d885f3252/src/CMakeProject1/CMakeProject1.cpp:103

It seems that the function pointer passing in is invalid (0xfffffff0). And it implies there is something wrong with the Lua stack?

Compiling the exact code as standalone executable is OK, no segfault and the result is correct.

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda