[PATCH 1/2] Make 'clear_dive()' free the primary dive computer data properly

Rick Walsh rickmwalsh at gmail.com
Thu Jun 9 16:19:02 PDT 2016


Linus,

On 1 June 2016 at 03:10, Linus Torvalds <torvalds at linux-foundation.org>
wrote:

>
> From: Linus Torvalds <torvalds at linux-foundation.org>
> Date: Mon, 11 Apr 2016 14:25:03 -0700
> Subject: [PATCH 1/2] Make 'clear_dive()' free the primary dive computer
> data properly
>
> Our primary dive computer really is special, not just because it's the
> first one: it's directly embedded in the "struct dive", and so if you
> just walk the divecomputer list, you'll miss it, because it's not _on_
> the list, it is the very head _of_ the list.
>
> We had that bug in copy_dive(), and it turns out we have it in
> clear_dive() too: clear_dive() would free all the dive computers on the
> list, but not the actual primary one.
>
> This is a minor memory leak, no more, so it's not exactly critial, but
> let's just do it right.
>
> Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
> ---
>  core/dive.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
>
>
This change leads to an invalid pointer error when cancelling a planned
dive.

*** Error in `/home/rick/src/subsurface/build/subsurface': munmap_chunk():
invalid pointer: 0x0000000000803f5d ***
======= Backtrace: =========
/lib64/libc.so.6(+0x77d75)[0x7ffff0e50d75]
/lib64/libc.so.6(cfree+0x1a8)[0x7ffff0e5c888]
/home/rick/src/subsurface/build/subsurface[0x6946b6]
/home/rick/src/subsurface/build/subsurface(clear_dive+0x7f)[0x69044d]
/home/rick/src/subsurface/build/subsurface(copy_dive+0x1c)[0x69055e]
/home/rick/src/subsurface/build/subsurface(_ZN14ProfileWidget28plotDiveEP4diveb+0x116)[0x627fe8]
/home/rick/src/subsurface/build/subsurface(_ZN14ProfileWidget26replotEP4dive+0x47)[0x626de9]
/home/rick/src/subsurface/build/subsurface(_ZN10MainWindow14refreshProfileEv+0x4f)[0x512185]
/home/rick/src/subsurface/build/subsurface(_ZN10MainWindow12planCanceledEv+0x18)[0x5121bc]
/home/rick/src/subsurface/build/subsurface[0x5bafb3]
/lib64/libQt5Core.so.5(_ZN11QMetaObject8activateEP7QObjectiiPPv+0x690)[0x7ffff1c0bdf0]
/home/rick/src/subsurface/build/subsurface(_ZN22DivePlannerPointsModel12planCanceledEv+0x29)[0x685245]
/home/rick/src/subsurface/build/subsurface(_ZN22DivePlannerPointsModel10cancelPlanEv+0x39)[0x65d901]
/home/rick/src/subsurface/build/subsurface[0x684e43]

Do you know what the fix could be?

Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.subsurface-divelog.org/pipermail/subsurface/attachments/20160610/c4cfd5cf/attachment.html>


More information about the subsurface mailing list