[GRASS-dev] r.flow: crash on 64bit

Glynn Clements glynn at gclements.plus.com
Mon Jan 29 21:34:15 EST 2007


Markus Neteler wrote:

> when using r.flow on 64bit, it crashes (Spearfish example):
> r.flow elevation.dem flout=flout lgout=lgout dsout=dsout
> Reading input files: elevation
> Precomputing: tangents
> Precomputing: e/w distances
> Precomputing: quantization tolerances
> Precomputing: interpolated border elevations
> Precomputing: aspects
> Calculating maps ...
> Segmentation fault
> 
> It dies in calc.c:223.
> 
> A backtrace:

> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 182925195200 (LWP 26627)]
> 0x0000000000403e3f in next_point (p=0x7fbfffdf20, a=0x7fbfffdf10, b=0x7fbfffdf00, l=0x7fbfffdec0)
>     at calc.c:223
> 223         if (oldtheta != 90 && oldtheta != 270 &&          /* north/south */
> (gdb) bt full
> #0  0x0000000000403e3f in next_point (p=0x7fbfffdf20, a=0x7fbfffdf10, b=0x7fbfffdf00, l=0x7fbfffdec0)
>     at calc.c:223
>         sub = 0
>         cut = 2.356693130662746e-321
>         horiz = 2
>         semi = 1
>         length = 1.1899763912722237e-312
>         delta = 0
>         deltaz = 0
>         oldz = -nan(0xfffffffffffff)
>         oldtheta = -2147483648

oldtheta (initialised from p->theta) is used as an index into the
"tang" array, which has size 361 (i.e. valid indices are 0 to 360
inclusive). The value here is 0x80000000 (i.e. -2^31).

AFAICT, p->theta gets initialised from the result of the aspect()
macro (in mem.h), which uses aspect_fly() (from aspect.c) plus some
buffering via the segment library.

I can't really follow it beyond that. The code is quite poorly
written, making extensive use of macros containing free variables. 
Also, there seems to be some confusion between integer and FP values
(e.g. the result of aspect() is explicitly cast to a double before
being stored in an integer field).

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list