That's strange. Mine doesn't crash in jtprobe. It crashes in jtsymfree being called from jtsymfreeh where u is invalid memory on these lines:

 u=*wv+jt->sympv;
 RZ(symfree(u));

I'm not using the latest commit though. I am using this one:

commit 05d24010d132df1927c621b376b60135add93b36
Author: HenryHRich <henryhr...@gmail.com>
Date:   Wed Jul 27 18:01:36 2016 -0400


On 08/13/2016 11:49 PM, bill lam wrote:
I don't know what has happened or any idea about symbol table.
It crashed in s.c , back trace:

#0  0x00007ffff7065ff4 in jtprobe (jt=jt@entry=0x643e70,
a=<optimized out>,
    g=0x7ffff7f315a0) at /home/bill/gitdev/jsource/jsrc/s.c:167
#1  0x00007ffff7066467 in jtprobelocal (jt=jt@entry=0x643e70,
a=a@entry=0x7ffff7f31620)
    at /home/bill/gitdev/jsource/jsrc/s.c:202
#2  0x00007ffff70667f4 in jtsyrd (jt=jt@entry=0x643e70,
a=0x7ffff7f31620,
    symb=symb@entry=0x0) at
/home/bill/gitdev/jsource/jsrc/s.c:314
#3  0x00007ffff706b2ec in jtex (jt=jt@entry=0x643e70,
w=<optimized out>)
    at /home/bill/gitdev/jsource/jsrc/sn.c:205
#4  0x00007ffff717b09a in jttest (jt=0x643e70, w=0x7ffff7f317a0)
    at /home/bill/gitdev/jsource/jsrc/x.c:262
#5  0x00007ffff701a09b in jtdfs1 (jt=jt@entry=0x643e70,
w=<optimized out>,
    self=<optimized out>) at
/home/bill/gitdev/jsource/jsrc/au.c:32
#6  0x00007ffff705bdbd in jtparsea (jt=jt@entry=0x643e70,
w=w@entry=0x7ffff7f31320)
    at /home/bill/gitdev/jsource/jsrc/p.c:376
#7  0x00007ffff705c890 in jtparse (jt=jt@entry=0x643e70,
w=0x7ffff7f31320)
    at /home/bill/gitdev/jsource/jsrc/p.c:126
#8  0x00007ffff705ea5a in jtimmex (jt=jt@entry=0x643e70,
w=w@entry=0x7ffff7f312a0)
    at /home/bill/gitdev/jsource/jsrc/px.c:37
#9  0x00007ffff7052f0b in jdo (jt=jt@entry=0x643e70,
lp=<optimized out>)
    at /home/bill/gitdev/jsource/jsrc/io.c:148
#10 0x00007ffff7052f4a in JDo (jt=0x643e70, lp=<optimized out>)
    at /home/bill/gitdev/jsource/jsrc/io.c:203
#11 0x0000000000402422 in jedo ()
#12 0x000000000040240c in main ()

list starting from 161 (crashed at line 167), perhaps you may
want to reinstate line 166 for checking.

161     // a is A for name, g is symbol table
162     // result is L* address of the symbol-table entry for
the name, or 0 if not found
163     L*jtprobe(J jt,A a,A g){C*s;I*hv,m;L*v;NM*u;
164      RZ(a&&g);u=NAV(a);
165      // If there is bucket information,
166     // obsolete
ASSERTSYS(jt->local||(u->bucket==0&&u->bucketx==0),"bucket");
167      m=u->m; s=u->s;
hv=AV(g)+SYMHASH(u->hash,AN(g)-SYMLINFOSIZE);  // get bucket
number among the hash tables
168      if(!*hv)R 0;                            /* (0) empty
slot    */
169      v=*hv+jt->sympv;
170      while(1){
171       u=NAV(v->name);
172       if(m==u->m&&!memcmp(s,u->s,m))R v->val?v:0;     // (1)
exact match - if there is a value, use this slot, else say not
found
173       if(!v->next)R 0;                       /* (2) link
list end */
174       v=v->next+jt->sympv;
175     }}


Пт, 12 авг 2016, Thomas Costigliola написал(а):
I am having trouble with custom code that used to work but no longer does in
the latest beta sources. The trouble seems to be related to symbol tables
and/or reference counting etc. I managed to reduce the issues to a small
piece of code which crashes under some circumstances but does not in the
pre-805 J sources.

// in x.c
// Foreign 104 !: 1
...
case XC(104,1):  R CDERIV(CIBEAM, jttest, 0, RMAX, 0,   0  );
...

static F1(jttest){A z, n, loc=jt->local;
 RZ(w);
 RZ(jt->local=stcreate(2,1L,0L,0L));
 n=nfs(1,"A");
 IS(n,w);
 ex(box(cstr("A")));
 symfreeh(jt->local,0L);
 jt->local=loc;
 R w;
}

The code does the following:
1. Create a local symbol table
2. Assign the argument w to A in the local symbol table
3. Erase A in the local symbol table
4. Erase the local symbol table
5. Return the argument

Doing the following in the J session causes a crash in symfreeh due to
accessing invalid memory in jt->sympv

   104!:1 ] 1 2 3
1 2 3
   B=. 1 2 3
   104!:1 B
1 2 3
   104!:1 B
1 2 3
   104!:1 B
1 2 3
   104!:1 B
1 2 3
   104!:1 B
BOOM!

Is this a bug or is there a new way to deal with local symbol tables?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

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

Reply via email to