SIGFPE in fixup_divep at dive.c:479 when importing dive with duration == 0

Lutz Vieweg lvml at 5t9.de
Sat Aug 18 09:55:29 PDT 2012


On 08/18/2012 06:20 PM, Linus Torvalds wrote:
>> Obvious cause is line dive.c:479, which divides by zero if the dive duration
>> is zero:
>
> Ok. That code had some other problems too, I've pushed out all the
> pending fixes.

Thanks!

> 		/* Assume an ascent/descent rate of 9 m/min */
> 		int depth = dive->maxdepth.mm;
> 		int asc_desc_time = depth*60/9000;
> 		int duration = dive->duration.seconds;
>
> 		/* Protect against insane dives - make mean be half of max */
> 		if (duration <= asc_desc_time) {
> 			duration = 2;
> 			asc_desc_time = 1;
> 		}
> 		dive->meandepth.mm = depth*(duration-asc_desc_time)/duration;

If (dive->maxdepth.mm < 0 && dive->duration.seconds == 0), this could 
theoretically still crash, though...

(I know, dives into negative depths are not common, but physically well 
possible... just imagine you have drowned a large hemisphere into your 
big swimming pool, tied a rope to its zenith, used a crane to drag the 
hemisphere out of the water, but only so far that its lower edge is 
still under water... then you can jump in your pool, and dive up into 
the water-filled hemisphere... into a "negative depth"... will expose 
you to a significant DCS risk, though. :-)

Regards,

Lutz Vieweg


More information about the subsurface mailing list