Skip to content

Commit a62c8b0

Browse files
committed
Fix GCobj pointer comparison in BC_ISEQV/BC_ISNEV
When comparing GC objects payload (i.e. their GCobj pointers) in scope of BC_ISEQV/BC_ISNEV bytecodes, both values are loaded into the 64-bit registers, but only lower 32 bits are compared later. Hence, there might be the address parts clashing, leading to invalid comparison results, when the LSBs are the same, but the MSBs are not. This register mischoice was introduced in the very first uJIT commit, since VM code had been taken intact from vanilla LuaJIT sources, but 128-bit TValue (and, ergo, 64-bit GCobj pointers) are uJIT specifics. So, this is likely a typo, undetected since 2015. As a result of the patch, 64-bit registers are used in this <cmp> instruction. Unfortunately, I have no reproducer for this, so I can't provide a proper test for this changeset. Signed-off-by: Igor Munkin <imun@cpan.org>
1 parent e0e89c8 commit a62c8b0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/vm_x86.dasc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2709,7 +2709,7 @@ static void build_ins(BuildCtx *ctx, BCOp op, int defop)
27092709
| // Same types and not a primitive type. Compare GCobj or pvalue.
27102710
| i2gcr GCOBJ:RAa, BASE, RAa // RA := GCobj*
27112711
| i2gcr GCOBJ:RDa, BASE, RDa // RD := GCobj*
2712-
| cmp RA, RD
2712+
| cmp RAa, RDa
27132713
| je <1 // Same GCobjs or pvalues?
27142714
| cmp RB, LJ_TISTABUD
27152715
| ja <2 // Different objects and not table/ud?

0 commit comments

Comments
 (0)