Segfault when using planner

Lubomir I. Ivanov neolit123 at gmail.com
Tue Feb 12 13:51:15 PST 2013


On 12 February 2013 23:12, Dirk Hohndel <dirk at hohndel.org> wrote:
> Chris Lewis <chrislewis915 at gmail.com> writes:
>
>> Hi,
>>
>> I've been playing with the planner and can repeatably get it to segfault.
>>
>> Set a new plan and enter the following lines
>>
>> 1. 30m 2 minutes 32%
>> 2. 30m 20 mins 32%
>> 3. 45m 10mins Air
>>
>> when choosing Air in the drop down i get :
>>
>> can't find gas 20/0
>> Segmentation fault (core dumped)
>
> The bug is obvious. We mark AIR as o2=209, yet the gas change events
> only support whole percent, so we get o2=200 and therefore can't find
> it. Duh. I'll fix that.
>
> I don't understand why you are getting a SIGSEGV, though. Which OS are
> you trying this on?
>

i think i can confirm the segfault,

looks like in add_plan_to_notes()'s "do...while loop" at one point
get_gasidx() returns -1, which then is part of the
offset sum consumption[gasidx] += used.

having a negative offset is valid c, but apparently at least here on
ubuntu, this increments the address stored at -1;
which somehow was the address of diveplan.

here is a patch to illustrate, unfortunately i cannot submit a real
patch as i don't understand the math in the planner. :(
perhaps the fix should be in get_gasidx(), to always return a valid gas index.

lubomir
--
-------------- next part --------------
A non-text attachment was scrubbed...
Name: planner.patch
Type: application/octet-stream
Size: 443 bytes
Desc: not available
URL: <http://lists.hohndel.org/pipermail/subsurface/attachments/20130212/d1682df6/attachment.obj>


More information about the subsurface mailing list