lua-users home
lua-l archive

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


On Tue, 2 Oct 2007 09:51:26 +0100, Robert Raschke <rrlua@tombob.com>
wrote:

>Hi Steve,
>
>you answered Roberto's question:
>> > Are
>> > you sure the bug is not a "regular" bug in your
>> > program? 
>>
>> I'm pretty certain of that.
>
>And then a bit later you say:
>> I would really like to do that, but this is a fairly
>> large system consisting of tens of thousands of lines
>> of code. Since the bug is so hard to reproduce even
>> with the whole system, it may take me a very long time
>> to get it to show up in a small sample.
>
>How do you get to be so certain that your code is correct?

I'm not certain that my code is correct. I'm pretty certain that it
isn't producing irreproducible errors.

>Since Lua is a pretty extraordinarily stable platform (and very small,
>to boot), my first inclination is to doubt my own code when something
>breaks.  So far, this has been the case in 100% of all my problems.
>
>I would suggest you try investigating your problem in a bit more
>depth.  I like to debug using print statements.  Since you say that
>you are getting errors in different parts of your code, try adding
>some suitable prints into those places, to allow you to reaffirm your
>expected values.  Then with the results of those you may be able to
>backtrack in the code, adding more prints as you go along.

The problem is that every time I run the program and get errors, they
are in a different place, and they make no sense (that is, the
debugger shows that the data as I expect rather than as the error
indicates).

>Unfortunately, debugging is still a bit of a black art.  Kernighan and
>Pike cover a little bit in their Practice of Programming book, which
>is a very good read.

I'm quite good at debugging, and ldb is a tremendous help. But it
can't help me find errors that move around in the code.

If I were having the same difficulties in a C or C++ program, I would
suspect an uninitialized variable. However, precisely because Lua is
"safe" in that respect, and such things should not occur, it looks
like a Lua bug.

Steve