[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Serious (unreproducable) Problems
- From: Christian Vogler <Christian.Vogler@...>
- Date: Tue, 19 Oct 2004 21:24:46 -0400
Hi,
first of all, welcome to Lua.
On Tuesday 19 October 2004 09:12 pm, Nils Wogatzky wrote:
> I already tried to debug, but in Debug-Mode everything works fine.
>
> At least when I just cut-out or change the position of some lines in my
> script my application works again.
> This makes no sense, because it already did work well,
> why should i change the position of those Calls ?
I feel your pain. All these symptoms are indicative of a buffer overflow
somewhere in your program, or some other form of heap corruption (i.e. you
write past the end of an array, you free dynamically allocated memory twice,
you mix new with free() or malloc() with delete, etc. Unfortunately, the
cause and the location of the crash are often completely unrelated, so I am
afraid that finding the bug may require a long exercise in patience.
The reason why the behavior of your bug changes in debug mode, or when you
move around lines in the lua script, is that it changes the memory allocation
patterns of your program, and the heap corruption will consequently not
manifest, or in a different place. I've been there and done that, and the
only advice that I can give you is: Use a memory debugging tool, such as
Purify on Windows, Valgrind on Linux, etc. With any luck, it will pinpoint
exactly what is going wrong in your program.
> Do I have some trouble with LUA or with my use of memory ? ;-)
Most likely your use of memory, but it won't hurt to rule out a few things.
First, do you store a Lua object past the point when your called C++ function
returns? If yes, you need to look at your use of lua_ref(). Second, do you
possibly store a reference to a C++ object from within Lua, and it gets
deallocated, garbage-collected, or such like?
Good luck
- Christian