lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi, everyone!
   I find a problem which gets a wrong result on our app server(Centos6.7)  occasionally.
 In short, I add a function in lua source:

char* test(char *lua_script, char *lua_field){

    lua_State *L = luaL_newstate();

    luaL_openlibs(L);

    luaL_dostring(L, lua_script);

    lua_getglobal(L, lua_field);

    char* result = (char *)lua_tostring(L, -1);

    printf("before lua_close %s", result);

    lua_close(L);

    printf("after lua_close %s", result);

    return result;

}


And build liblua.so, then call 'test' via python ctypes, 'lua_script' passes 'test_key = 7174025728' and 'lua_field' passes 'test_key'.

Print is confusing, "before lua_close 7174025728" is sure but "after lua_close 7174025728" is not sure, sometimes print "after lua_close 717402570"!.

Different strings have different results, some have one more char that is the most probable '0' at the end and some get a substring.


I try lua-5.1.5 & lua-5.3.4 and cannot find the problem on Android, iOS, MacOS, Ubuntu, just only on Centos


Thank you!