I don't know what might have changed. rat1() raises the usecount only on the top-level name, so if the sparse array points to other blocks they will not have the usecount incremented.

Henry Rich

On 6/2/2017 10:47 AM, Thomas Costigliola wrote:
I have this patch that implements sparse boxing that worked in the J805 engine. Sometime between 805 and 806 it stopped working and now crashes the interpreter during or after the result gets freed.

< $. 1 0 0 2

Can someone (Henry) explain what changed?

Here is the patch:

diff --git a/jsrc/cu.c b/jsrc/cu.c
index ea70060..db2166c 100644
--- a/jsrc/cu.c
+++ b/jsrc/cu.c
@@ -9,7 +9,7 @@

 static A jteverysp(J jt,A w,A fs,AF f1){A*wv,x,z,*zv;P*wp,*zp;
  RZ(w);
- ASSERT(SBOX&AT(w),EVNONCE);
+ //ASSERT(SBOX&AT(w),EVNONCE);
  RZ(z=ca(w));
  wp=PAV(w); x=SPA(wp,x); wv=AAV(x);
  zp=PAV(z); x=SPA(zp,x); zv=AAV(x);
@@ -17,7 +17,7 @@ static A jteverysp(J jt,A w,A fs,AF f1){A*wv,x,z,*zv;P*wp,*zp;
  R z;
 }

-#define EVERYI(exp)  {RZ(*zv++=x=exp); ASSERT(!(SPARSE&AT(x)),EVNONCE);}
+#define EVERYI(exp) {RZ(*zv++=x=exp); /*ASSERT(!(SPARSE&AT(x)),EVNONCE);*/}
      /* note: x can be non-noun */

 A jtevery(J jt,A w,A fs,AF f1){A*wv,x,z,*zv;I wd;
diff --git a/jsrc/vo.c b/jsrc/vo.c
index 29d118c..a8b20ac 100644
--- a/jsrc/vo.c
+++ b/jsrc/vo.c
@@ -17,8 +17,22 @@ F1(jtlevel1){RZ(w); R sc(level(w));}

 F1(jtbox0){R irs1(w,0L,0L,jtbox);}

+F1(jtboxsp){A z, *zv;I r, n;
+ if(jt->rank){
+  r=jt->rank[1]; jt->rank=0;
+  z=denseit(w);
+  z=df1(z,qq(ds(CLT),sc(r)));
+  z=every(z,0,jtsparse1);
+ }else{
+  GATV(z,BOX,1,0,0); zv=AAV(z);
+  rat1(w); *zv=w;
+ }
+ R z;
+}
+
 F1(jtbox){A y,z,*zv;C*wv,*yv;I f,k,m,n,r,wr,*ws;
  RZ(w);
+ if(SPARSE&AT(w)) R jtboxsp(jt,w);
  ASSERT(!(SPARSE&AT(w)),EVNONCE);
  ws=AS(w); wr=AR(w); r=jt->rank?jt->rank[1]:wr; f=wr-r;
  RE(n=prod(f,ws)); if(n)m=AN(w)/n; else RE(m=prod(r,f+ws));

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


---
This email has been checked for viruses by AVG.
http://www.avg.com

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to