boxmein / leansand

Falling sand game with a tiny core and Lua everything
MIT License
2 stars 2 forks source link

Valgrind crash #5

Open Ristovski opened 9 years ago

Ristovski commented 9 years ago

The version of leansand from lua-api branch seems to crash when run through valgrind. Master and develop seem to run fine (and leak memory on linux, driver-related)

rafael@RPC:~/leansand/build$ valgrind ./leansand
==30788== Memcheck, a memory error detector
==30788== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==30788== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==30788== Command: ./leansand
==30788== 
luaL_newstate returned NULL, memory allocation error!==30788== Invalid read of size 4
==30788==    at 0x53A0A77: lua_pushcclosure (in /usr/lib/libluajit-5.1.so.2.0.4)
==30788==    by 0x53AECDD: luaL_openlibs (in /usr/lib/libluajit-5.1.so.2.0.4)
==30788==    by 0x40496E: LuaAPIManager::LuaAPIManager() (in /home/rafael/leansand/build/leansand)
==30788==    by 0x4057E3: __static_initialization_and_destruction_0(int, int) (in /home/rafael/leansand/build/leansand)
==30788==    by 0x40582B: _GLOBAL__sub_I_old_cerr (in /home/rafael/leansand/build/leansand)
==30788==    by 0x40684C: __libc_csu_init (in /home/rafael/leansand/build/leansand)
==30788==    by 0x5E8271E: (below main) (in /usr/lib/libc-2.21.so)
==30788==  Address 0x8 is not stack'd, malloc'd or (recently) free'd
==30788== 
==30788== 
==30788== Process terminating with default action of signal 11 (SIGSEGV)
==30788==  Access not within mapped region at address 0x8
==30788==    at 0x53A0A77: lua_pushcclosure (in /usr/lib/libluajit-5.1.so.2.0.4)
==30788==    by 0x53AECDD: luaL_openlibs (in /usr/lib/libluajit-5.1.so.2.0.4)
==30788==    by 0x40496E: LuaAPIManager::LuaAPIManager() (in /home/rafael/leansand/build/leansand)
==30788==    by 0x4057E3: __static_initialization_and_destruction_0(int, int) (in /home/rafael/leansand/build/leansand)
==30788==    by 0x40582B: _GLOBAL__sub_I_old_cerr (in /home/rafael/leansand/build/leansand)
==30788==    by 0x40684C: __libc_csu_init (in /home/rafael/leansand/build/leansand)
==30788==    by 0x5E8271E: (below main) (in /usr/lib/libc-2.21.so)
==30788==  If you believe this happened as a result of a stack
==30788==  overflow in your program's main thread (unlikely but
==30788==  possible), you can try to increase the size of the
==30788==  main thread stack using the --main-stacksize= flag.
==30788==  The main thread stack size used in this run was 8388608.
==30788== 
==30788== HEAP SUMMARY:
==30788==     in use at exit: 72,704 bytes in 1 blocks
==30788==   total heap usage: 1 allocs, 0 frees, 72,704 bytes allocated
==30788== 
==30788== LEAK SUMMARY:
==30788==    definitely lost: 0 bytes in 0 blocks
==30788==    indirectly lost: 0 bytes in 0 blocks
==30788==      possibly lost: 0 bytes in 0 blocks
==30788==    still reachable: 72,704 bytes in 1 blocks
==30788==         suppressed: 0 bytes in 0 blocks
==30788== Rerun with --leak-check=full to see details of leaked memory
==30788== 
==30788== For counts of detected and suppressed errors, rerun with: -v
==30788== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
Segmentation fault (core dumped)
boxmein commented 9 years ago

https://github.com/boxmein/leansand/blob/master/src/LuaGlobalAPI.cpp#L7 This is the specific error line valgrind also displays. This implies that valgrind is somehow stopping Lua from getting a new thread or enough memory to actually run its code.