This is a blunder and will be fixed in the next release. Thanks.

Henry Rich

On 3/8/2018 3:55 PM, Chris Double wrote:
Running jconsole through valgrind picked up a conditional check in
jtjprx in f.c depending on an uninitialized value.

The check occurs here:

https://github.com/jsoftware/jsource/blob/332c18ced323d33ae50d9551ab4d52d18e158375/jsrc/f.c#L804

The relevant code block being:

case 1:
// LIT characters. Copy them. If there were boxing characters about,
copy one by one and translate if boxing chars
// No need to suppress NULs - if the result is LIT, all boxes must
have converted to LIT, and would have had NUL converted to space
if(nbx){DO(c1, x=*v++; BDC(zv,x);); if(c1<c){v+=c-c1; DDD(zv);}}
// Otherwise just move fast

Here, nbx can be uninitialized (ie. set to a random memory value)
unless certain conditions are met with parsing.

It is declared here:

https://github.com/jsoftware/jsource/blob/332c18ced323d33ae50d9551ab4d52d18e158375/jsrc/f.c#L706

static A jtjprx(J jt,I ieol,I maxlen,I lb,I la,A w){A y,z;B ch;C
e,eov[2],*v,x,*zu,*zv;D lba; I c,c1,h,i,j,k,lc,m,nbx,nq,p,q,r,*s,t,zn;

and is initialized in the following line:

https://github.com/jsoftware/jsource/blob/332c18ced323d33ae50d9551ab4d52d18e158375/jsrc/f.c#L733

if(ch||AT(w)&BOX+SPARSE)zn+=nbx=countonlines(scanbdc,t,v,h,nq,c,lb,la);

It can be demonstrated outside of valgrind by adding a print statement
just before the check in line 804 to print the value of nbx. With this
print statement in affect, here's a console session:

$ ./bin/jconsole
    1
nbx: -1692375296
1
     <1
nbx: 24
1

$ ./bin/jconsole -lib libj-nonavx.so
    1
nbx: 977359104
1
     <1
nbx: 24
1

Note that an unboxed expression shows random uninitialized values for
nbx on each run. An expression containing the box character triggers
the initialization in line 733 and shows a reasonable value.

The net affect of this is that the "otherwise move fast" else block in
the if loop probably never gets hit unless nbx happens to randomly
initialize to zero.



---
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