[GRASS5] r.texture segfault
Markus Neteler
neteler at itc.it
Thu Jun 30 09:25:48 EDT 2005
On Thu, Jun 30, 2005 at 10:15:15PM +1200, Hamish wrote:
> > > 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.
Right, I found the same.
> Apparently the module was never updated for NULL support?
I think that G_get_raster_row() should do the job.
But probably the r.rescale isn't? Means that r.reclass shows
a problem as r.rescale does a system call?
> 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.
Please apply the needed patch.
> > 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
I'm not sure how to fix the NULL/-2147483648 problem.
Markus
More information about the grass-dev
mailing list