0

After executing a script that uses our internal objects mapped using LuaBridge, the Lua commandline executable crashes.

**Call Stack**

Compiler.exe!l_alloc(void * ud, void * ptr, unsigned int osize, unsigned int nsize) Line 1003   C
Compiler.exe!luaM_realloc_(lua_State * L, void * block, unsigned int osize, unsigned int nsize) Line 86 C
Compiler.exe!luaH_free(lua_State * L, Table * t) Line 418   C
Compiler.exe!freeobj(lua_State * L, GCObject * o) Line 707  C
Compiler.exe!sweeplist(lua_State * L, GCObject * * p, unsigned int count) Line 743  C
Compiler.exe!luaC_freeallobjects(lua_State * L) Line 973    C
Compiler.exe!close_state(lua_State * L) Line 245    C
Compiler.exe!lua_close(lua_State * L) Line 344  C
Compiler.exe!main(int argc, char * * argv) Line 606 C

Values
ud = 0x00000000
ptr = 0x0ffb8690
osize = 32
nsize = 0

Code

static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize)
{

(void)ud; (void)osize;  /* not used */

if (nsize == 0) 
>{
    free(ptr);

return NULL;

}

else
    return realloc(ptr, nsize);

}

Error

Exception thrown at 0x50B8461D (ucrtbased.dll) in Compiler.exe: 0xC0000005: Access violation reading location 0x0FFB868C.

If there is a handler for this exception, the program may be safely continued.

Any hints on how to handle this. Apparently this might a memory allocation issue within our code but should Lua handle this properly?

LPs
  • 16,045
  • 8
  • 30
  • 61
TrustyCoder
  • 4,749
  • 10
  • 66
  • 119
  • Where is *your* code? Often if Lua crashes on exit it's to do with its stack not being cleared properly. Make sure you are popping the correct amount of values everywhere. You can check by using `lua_gettop`. – Gambit Mar 27 '17 at 23:40
  • Is there a way to prevent this even if there are leaks within the lua interfacing code. We are using Lua bridge to map classes and methods. – TrustyCoder Mar 27 '17 at 23:56
  • I haven't used LuaBridge myself so I can't help you in that regard. Try commenting out blocks of code that use Lua(Bridge) until it stops crashing. Once you have found a block that crops the crashing try uncommenting it and other blocks until it crashes again. – Gambit Mar 28 '17 at 00:02

0 Answers0