u3: check for road stack overflow on every nock %2 and %9
@@ -1838,6 +1838,23 @@ _n_kale(u3_noun a)
return a;
}
+/* _n_sane(): check for stack overflow
+*/
+static inline void
+_n_sane(c3_ys off_ys)
+{
+ if ( !off_ys ) {
+ if( !(u3R->cap_p > u3R->hat_p) ) {
+ u3m_bail(c3__meme);
+ }
+ }
+ else {
+ if( !(u3R->cap_p < u3R->hat_p) ) {
+ u3m_bail(c3__meme);
+ }
+ }
+}
+
typedef struct {
u3n_prog* pog_u;
c3_w ip_w;
@@ -2078,6 +2095,7 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off)
x = _n_pep(mov, off);
fam = u3to(burnframe, u3R->cap_p) + off + mov;
u3R->cap_p = u3of(burnframe, fam - off);
+ _n_sane(off);
fam->ip_w = ip_w;
fam->pog_u = pog_u;
_n_push(mov, off, x);
@@ -2240,6 +2258,7 @@ _n_burn(u3n_prog* pog_u, u3_noun bus, c3_ys mov, c3_ys off)
fam = u3to(burnframe, u3R->cap_p) + off + mov;
u3R->cap_p = u3of(burnframe, fam - off);
+ _n_sane(off);
fam->ip_w = ip_w;
fam->pog_u = pog_u;
