|
 |
006bc1 |
commit 749e99ce2a88bf337bd2f6279940d6761ce5f616
|
|
 |
006bc1 |
Merge: e2cc89b 380e440
|
|
 |
006bc1 |
Author: Mike Pall <mike>
|
|
 |
006bc1 |
Date: Thu Jan 10 12:24:17 2019 +0100
|
|
 |
006bc1 |
|
|
 |
006bc1 |
Merge branch 'master' into v2.1
|
|
 |
006bc1 |
|
|
 |
006bc1 |
From 380e4409a70725df85034f02c968b6ebd7a5e513 Mon Sep 17 00:00:00 2001
|
|
 |
006bc1 |
From: Mike Pall <mike>
|
|
 |
006bc1 |
Date: Thu, 10 Jan 2019 12:19:30 +0100
|
|
 |
006bc1 |
Subject: [PATCH 54/72] Fix overflow of snapshot map offset.
|
|
 |
006bc1 |
|
|
 |
006bc1 |
Thanks to Yichun Zhang.
|
|
 |
006bc1 |
---
|
|
 |
006bc1 |
src/lj_jit.h | 10 +++++-----
|
|
 |
006bc1 |
src/lj_opt_loop.c | 8 ++++----
|
|
 |
006bc1 |
src/lj_snap.c | 6 +++---
|
|
 |
006bc1 |
3 files changed, 12 insertions(+), 12 deletions(-)
|
|
 |
006bc1 |
|
|
 |
006bc1 |
diff --git a/src/lj_jit.h b/src/lj_jit.h
|
|
 |
006bc1 |
index 3f38d28..0bc6258 100644
|
|
 |
006bc1 |
--- a/src/lj_jit.h
|
|
 |
006bc1 |
+++ b/src/lj_jit.h
|
|
 |
006bc1 |
@@ -163,7 +163,7 @@ typedef struct MCLink {
|
|
 |
006bc1 |
|
|
 |
006bc1 |
/* Stack snapshot header. */
|
|
 |
006bc1 |
typedef struct SnapShot {
|
|
 |
006bc1 |
- uint16_t mapofs; /* Offset into snapshot map. */
|
|
 |
006bc1 |
+ uint32_t mapofs; /* Offset into snapshot map. */
|
|
 |
006bc1 |
IRRef1 ref; /* First IR ref for this snapshot. */
|
|
 |
006bc1 |
uint8_t nslots; /* Number of valid slots. */
|
|
 |
006bc1 |
uint8_t topslot; /* Maximum frame extent. */
|
|
 |
006bc1 |
@@ -217,17 +217,15 @@ typedef enum {
|
|
 |
006bc1 |
/* Trace object. */
|
|
 |
006bc1 |
typedef struct GCtrace {
|
|
 |
006bc1 |
GCHeader;
|
|
 |
006bc1 |
- uint8_t topslot; /* Top stack slot already checked to be allocated. */
|
|
 |
006bc1 |
- uint8_t linktype; /* Type of link. */
|
|
 |
006bc1 |
+ uint16_t nsnap; /* Number of snapshots. */
|
|
 |
006bc1 |
IRRef nins; /* Next IR instruction. Biased with REF_BIAS. */
|
|
 |
006bc1 |
#if LJ_GC64
|
|
 |
006bc1 |
uint32_t unused_gc64;
|
|
 |
006bc1 |
#endif
|
|
 |
006bc1 |
GCRef gclist;
|
|
 |
006bc1 |
IRIns *ir; /* IR instructions/constants. Biased with REF_BIAS. */
|
|
 |
006bc1 |
IRRef nk; /* Lowest IR constant. Biased with REF_BIAS. */
|
|
 |
006bc1 |
- uint16_t nsnap; /* Number of snapshots. */
|
|
 |
006bc1 |
- uint16_t nsnapmap; /* Number of snapshot map elements. */
|
|
 |
006bc1 |
+ uint32_t nsnapmap; /* Number of snapshot map elements. */
|
|
 |
006bc1 |
SnapShot *snap; /* Snapshot array. */
|
|
 |
006bc1 |
SnapEntry *snapmap; /* Snapshot map. */
|
|
 |
006bc1 |
GCRef startpt; /* Starting prototype. */
|
|
 |
006bc1 |
@@ -241,6 +239,8 @@ typedef struct GCtrace {
|
|
 |
006bc1 |
TraceNo1 nextroot; /* Next root trace for same prototype. */
|
|
 |
006bc1 |
TraceNo1 nextside; /* Next side trace of same root trace. */
|
|
 |
006bc1 |
uint8_t sinktags; /* Trace has SINK tags. */
|
|
 |
006bc1 |
+ uint8_t topslot; /* Top stack slot already checked to be allocated. */
|
|
 |
006bc1 |
+ uint8_t linktype; /* Type of link. */
|
|
 |
006bc1 |
uint8_t unused1;
|
|
 |
006bc1 |
#ifdef LUAJIT_USE_GDBJIT
|
|
 |
006bc1 |
void *gdbjit_entry; /* GDB JIT entry. */
|
|
 |
006bc1 |
diff --git a/src/lj_opt_loop.c b/src/lj_opt_loop.c
|
|
 |
006bc1 |
index 36317b3..cc88111 100644
|
|
 |
006bc1 |
--- a/src/lj_opt_loop.c
|
|
 |
006bc1 |
+++ b/src/lj_opt_loop.c
|
|
 |
006bc1 |
@@ -223,7 +223,7 @@ static void loop_subst_snap(jit_State *J, SnapShot *osnap,
|
|
 |
006bc1 |
}
|
|
 |
006bc1 |
J->guardemit.irt = 0;
|
|
 |
006bc1 |
/* Setup new snapshot. */
|
|
 |
006bc1 |
- snap->mapofs = (uint16_t)nmapofs;
|
|
 |
006bc1 |
+ snap->mapofs = (uint32_t)nmapofs;
|
|
 |
006bc1 |
snap->ref = (IRRef1)J->cur.nins;
|
|
 |
006bc1 |
snap->nslots = nslots;
|
|
 |
006bc1 |
snap->topslot = osnap->topslot;
|
|
 |
006bc1 |
@@ -251,7 +251,7 @@ static void loop_subst_snap(jit_State *J, SnapShot *osnap,
|
|
 |
006bc1 |
nmap += nn;
|
|
 |
006bc1 |
while (omap < nextmap) /* Copy PC + frame links. */
|
|
 |
006bc1 |
*nmap++ = *omap++;
|
|
 |
006bc1 |
- J->cur.nsnapmap = (uint16_t)(nmap - J->cur.snapmap);
|
|
 |
006bc1 |
+ J->cur.nsnapmap = (uint32_t)(nmap - J->cur.snapmap);
|
|
 |
006bc1 |
}
|
|
 |
006bc1 |
|
|
 |
006bc1 |
typedef struct LoopState {
|
|
 |
006bc1 |
@@ -362,7 +362,7 @@ static void loop_unroll(jit_State *J)
|
|
 |
006bc1 |
}
|
|
 |
006bc1 |
}
|
|
 |
006bc1 |
if (!irt_isguard(J->guardemit)) /* Drop redundant snapshot. */
|
|
 |
006bc1 |
- J->cur.nsnapmap = (uint16_t)J->cur.snap[--J->cur.nsnap].mapofs;
|
|
 |
006bc1 |
+ J->cur.nsnapmap = (uint32_t)J->cur.snap[--J->cur.nsnap].mapofs;
|
|
 |
006bc1 |
lua_assert(J->cur.nsnapmap <= J->sizesnapmap);
|
|
 |
006bc1 |
*psentinel = J->cur.snapmap[J->cur.snap[0].nent]; /* Restore PC. */
|
|
 |
006bc1 |
|
|
 |
006bc1 |
@@ -376,7 +376,7 @@ static void loop_undo(jit_State *J, IRRef ins, SnapNo nsnap, MSize nsnapmap)
|
|
 |
006bc1 |
SnapShot *snap = &J->cur.snap[nsnap-1];
|
|
 |
006bc1 |
SnapEntry *map = J->cur.snapmap;
|
|
 |
006bc1 |
map[snap->mapofs + snap->nent] = map[J->cur.snap[0].nent]; /* Restore PC. */
|
|
 |
006bc1 |
- J->cur.nsnapmap = (uint16_t)nsnapmap;
|
|
 |
006bc1 |
+ J->cur.nsnapmap = (uint32_t)nsnapmap;
|
|
 |
006bc1 |
J->cur.nsnap = nsnap;
|
|
 |
006bc1 |
J->guardemit.irt = 0;
|
|
 |
006bc1 |
lj_ir_rollback(J, ins);
|
|
 |
006bc1 |
diff --git a/src/lj_snap.c b/src/lj_snap.c
|
|
 |
006bc1 |
index e891f7a..73f2500 100644
|
|
 |
006bc1 |
--- a/src/lj_snap.c
|
|
 |
006bc1 |
+++ b/src/lj_snap.c
|
|
 |
006bc1 |
@@ -129,11 +129,11 @@ static void snapshot_stack(jit_State *J, SnapShot *snap, MSize nsnapmap)
|
|
 |
006bc1 |
nent = snapshot_slots(J, p, nslots);
|
|
 |
006bc1 |
snap->nent = (uint8_t)nent;
|
|
 |
006bc1 |
nent += snapshot_framelinks(J, p + nent, &snap->topslot);
|
|
 |
006bc1 |
- snap->mapofs = (uint16_t)nsnapmap;
|
|
 |
006bc1 |
+ snap->mapofs = (uint32_t)nsnapmap;
|
|
 |
006bc1 |
snap->ref = (IRRef1)J->cur.nins;
|
|
 |
006bc1 |
snap->nslots = (uint8_t)nslots;
|
|
 |
006bc1 |
snap->count = 0;
|
|
 |
006bc1 |
- J->cur.nsnapmap = (uint16_t)(nsnapmap + nent);
|
|
 |
006bc1 |
+ J->cur.nsnapmap = (uint32_t)(nsnapmap + nent);
|
|
 |
006bc1 |
}
|
|
 |
006bc1 |
|
|
 |
006bc1 |
/* Add or merge a snapshot. */
|
|
 |
006bc1 |
@@ -294,7 +294,7 @@ void lj_snap_shrink(jit_State *J)
|
|
 |
006bc1 |
snap->nent = (uint8_t)m;
|
|
 |
006bc1 |
nlim = J->cur.nsnapmap - snap->mapofs - 1;
|
|
 |
006bc1 |
while (n <= nlim) map[m++] = map[n++]; /* Move PC + frame links down. */
|
|
 |
006bc1 |
- J->cur.nsnapmap = (uint16_t)(snap->mapofs + m); /* Free up space in map. */
|
|
 |
006bc1 |
+ J->cur.nsnapmap = (uint32_t)(snap->mapofs + m); /* Free up space in map. */
|
|
 |
006bc1 |
}
|
|
 |
006bc1 |
|
|
 |
006bc1 |
/* -- Snapshot access ----------------------------------------------------- */
|
|
 |
006bc1 |
--
|
|
 |
006bc1 |
2.20.1
|
|
 |
006bc1 |
|