[Tarantool-patches] [PATCH luajit] gdb: fix misalignment in lj-stack for LJ_GC64

Igor Munkin imun at tarantool.org
Thu Jul 22 16:35:32 MSK 2021


Misha,

I've checked the patch into all long-term branches in tarantool/luajit
and bumped a new version in 1.10, 2.7, 2.8 and master.

On 07.07.21, Mikhail Shishatskiy wrote:
> Since commit 58790750b9c4bd4c21d883f109ab552a2e202a15 ('gdb: introduce
> luajit-gdb extension') when luajit-gdb.py is introduced, Lua stack
> slots printed by lj-stack command are misaligned, when LJ_GC64 is
> enabled. The issue is that PADDING variable used for aligning single
> slots in the output is initialized before LuaJIT build mode is
> defined in <init> function, so the result was the following:
> 
> | 0x7ffff7fb0d90:0x7ffff7fb0dc0 [    ] 7 slots: Red zone
> | 0x7ffff7fb0d88            [   M]
> | 0x7ffff7fb0cc0:0x7ffff7fb0d80 [    ] 25 slots: Free stack slots
> | 0x7ffff7fb0cb8            [  T ]
> | ...
> 
> In scope of this patch, PADDING initialization is also moved to
> <init> function right after all commands are loaded. As a result, the
> output looks as expected:
> 
> | 0x7ffff7fb0d90:0x7ffff7fb0dc0 [    ] 7 slots: Red zone
> | 0x7ffff7fb0d88                [   M]
> | 0x7ffff7fb0cc0:0x7ffff7fb0d80 [    ] 25 slots: Free stack slots
> | 0x7ffff7fb0cb8                [  T ]
> | ...
> 
> Fixes tarantool/tarantool#5876
> ---
> 
> Branch: https://github.com/tarantool/luajit/tree/shishqa/gh-5876
> 
> To test changes do the following:
> 
> | $ gdb -q --args ./luajit -e 'print("QQ")'
> | Reading symbols from ./luajit...
> | lj-arch command initialized
> | lj-tv command initialized
> | lj-str command initialized
> | lj-tab command initialized
> | lj-stack command initialized
> | lj-state command initialized
> | lj-gc command initialized
> | luajit-gdb.py is successfully loaded
> | (gdb) lj-arch
> | LJ_64: True, LJ_GC64: True
> | (gdb) b lj_cf_print
> | Breakpoint 1 at 0x298b0: file /mnt/WorkDisk/share/dev/__tarantool/lj-tarantool/src/lib_base.c, line 485.
> | (gdb) r
> | Starting program: /mnt/WorkDisk/share/dev/__tarantool/lj-tarantool/src/luajit -e print\(\"QQ\"\)
> |
> | Breakpoint 1, lj_cf_print (L=0x0)
> |     at /mnt/WorkDisk/share/dev/__tarantool/lj-tarantool/src/lib_base.c:485
> | 485	{
> | (gdb) s
> | 486	  ptrdiff_t i, nargs = L->top - L->base;
> | (gdb) lj-stack L
> | 0x7ffff7fa8d90:0x7ffff7fa8dc0 [    ] 7 slots: Red zone
> | 0x7ffff7fa8d88                [   M]
> | 0x7ffff7fa8cc0:0x7ffff7fa8d80 [    ] 25 slots: Free stack slots
> | 0x7ffff7fa8cb8                [  T ]
> | 0x7ffff7fa8cb0                [ B  ] VALUE: string "QQ" @ 0x7ffff7fb1178
> | 0x7ffff7fa8ca0:0x7ffff7fa8ca8 [    ] FRAME: [L] delta=2, fast function #29
> | 0x7ffff7fa8c90:0x7ffff7fa8c98 [    ] FRAME: [V] delta=2, Lua function @ 0x7ffff7fb1240, 0 upvalues, "=(command line)":0
> | 0x7ffff7fa8c80:0x7ffff7fa8c88 [    ] FRAME: [CP] delta=4, Lua function @ 0x7ffff7fb1240, 0 upvalues, "=(command line)":0
> | 0x7ffff7fa8c78                [    ] VALUE: C function @ 0x55555555c962
> | 0x7ffff7fa8c70                [    ] VALUE: light userdata @ 0x0
> | 0x7ffff7fa8c60:0x7ffff7fa8c68 [    ] FRAME: [CP] delta=2, C function @ 0x55555555df1c
> | 0x7ffff7fa8c58:0x7ffff7fa8c60 [S   ] FRAME: dummy L
> 
> 
>  src/luajit-gdb.py | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 

<snipped>

> -- 
> 2.32.0
> 

-- 
Best regards,
IM


More information about the Tarantool-patches mailing list