lua-users home
lua-l archive

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


On Fri, Oct 24, 2003 at 05:01:16PM -0700, Curt Carpenter wrote:
>
> I can repro this one. But I don't know the exact steps other than
> running our app, which involves a huge amount of Lua before the problem.
> But since I CAN repro, any suggestions on what to try, where to set a
> breakpoint, etc., would be appreciated. Just my luck that this happens
> on a Friday afternoon, when probably no one is around. :-)

brute force suggestion: add

	lua_assert((t->array == 0) == (t->sizearray == 0))

at the beginning of all functions in ltable.c that take a 'Table *t'
as an argument - maybe this will help narrow down the source of the
problem.

another one: if you can reproduce while running under a debugger and
your debugger supports watchpoints, you could put a watchpoint on the
relevant memory address once you've determined which 'Table *t' is
having the problem.

e.g. in the example below using gdb, i put a conditional breakpoint in
luaH_new() after the 't->array = NULL' line when the table allocated has
address 0x8074590.  once the debugger hits this breakpoint, it adds a
watchpoint on memory address 0x807459c which is the address of t->array.
the watchpoint triggers every time t->array changes.

----------------------------------

(gdb) b ltable.c:334 if t==0x8074590
Breakpoint 1 at 0x8058b86: file ltable.c, line 334.
(gdb) commands
Type commands for when breakpoint 1 is hit, one per line.
End with a line saying just "end".
>silent
>watch *0x807459c
>cont
>end
(gdb) run array.lua
Starting program: /usr/local/taj/bin/lua array.lua
Hardware watchpoint 2: *134694300
Hardware watchpoint 2: *134694300

Old value = 0
New value = 134694520
setarrayvector (L=0x806ff48, t=0x8074590, size=1) at ltable.c:242

242       for (i=t->sizearray; i<size; i++)
(gdb) p &t->array 
$1 = (struct lua_TObject **) 0x807459c
(gdb) c
Continuing.
Hardware watchpoint 2: *134694300

Old value = 134694520
New value = 134693800
setarrayvector (L=0x806ff48, t=0x8074590, size=2) at ltable.c:242
242       for (i=t->sizearray; i<size; i++)
(gdb) c
Continuing.
Hardware watchpoint 2: *134694300

Old value = 134693800
New value = 134695040
setarrayvector (L=0x806ff48, t=0x8074590, size=32) at ltable.c:242
242       for (i=t->sizearray; i<size; i++)
(gdb) c
Continuing.
Hardware watchpoint 2: *134694300

Old value = 134695040
New value = 1074057224
setarrayvector (L=0x806ff48, t=0x8074590, size=16384) at ltable.c:242
242       for (i=t->sizearray; i<size; i++)
(gdb) c
Continuing.

----------------------------------

-taj