lua-users home
lua-l archive

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

>Don't you want
> mem_used += (nsize - osize);
>in the last else block?

Yes, thanks for pointing that out!

Changing my_Alloc to:
static void *my_Alloc(void *ud, void *ptr, size_t osize, size_t nsize)
  (void) ud;
    if (nsize == 0)
      mem_used -= osize;
      return NULL;
    else if ((nsize - osize) + mem_used > limit)
      return NULL;
      mem_used += (nsize - osize);
      return realloc(ptr, nsize);

Does not seem to fix the problem however.

>In the code that you sent, it seems that the segfault is caused by a
>stack overflow. Each cpcall leaves at the stack the error message; if
>you do not pop it, they accumulate and overflow the stack. Once you
>add a lua_pop inside the loop, the code seems to run without problems.

That's what I suspected, but I believe there is a different problem
because my application gets this segfault in _one_ call to cpcall and
right after the Lua state is made. The segfault always occurs in the
call to free().

-Patrick Donnelly

"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."

-Will Durant