[GRASS5] r.texture segfault

Hamish hamish_nospam at yahoo.com
Thu Jun 30 06:15:15 EDT 2005


> > we found a bug in r.texture which I'm unable to resolve.
> >
> > To reproduce it in Spearfish, run
> > 
> >    g.region rast=spot.image -p
> >    r.rescale spot.image to=0,255 out=spot.resc
> >    r.texture in=spot.resc -v pref=spot.image size=10 distance=5
> >    Segmentation fault
> > 
> > I found with the debugger following
> > 
> > (gdb) r in=spot.resc -v pref=spot.image size=10 distance=5
> > Starting program:
> > /hardmnt/thuille0/ssi/software/cvsgrass61/dist.i686-pc-linux-gnu/bi
> > n/r.texture in=spot.resc -v pref=spot.image size=10 distance=5
> > Reading the raster map...done
> >    0%
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x08049574 in h_measure (grays=0x87798e0, rows=10, cols=10, t_m=12,
> > t_d=5)
> >     at h_measure.c:124
> > 124               while (tone[y] != grays[row][col + d])
..
> > The 'ddd' tells me that tone[y] is unavailable. Probably y get's
> > too large and then the crash occurs.


adding on line 126
  if(y>255) printf("grays[row][col + d]=%d\n", grays[row][col + d]);

we see that 

> >     at h_measure.c:124
> > 124               while (tone[y] != grays[row][col + d])

is trying to match tone[y] to -2147483648.


Apparently the module was never updated for NULL support?

Run 'r.null null=0' on spot.image first & it works ok.


by the way, 'r.colors rule=bcyr' looks a lot better than the default 
for the result file.




> r.texture/h_measure.c:
> 
> #define PGM_MAXMAXVAL 255
> int tone[PGM_MAXMAXVAL];
> 
> 
> That 255 should really be 256?
> 
> int tone[255];
> 
> allocates tone[0] -> tone[254], maybe it loops up the value of y
> trying  to match a grey value of 255 and then kerplunk?


still true?




Hamish




More information about the grass-dev mailing list