On Mon, Apr 11, 2016 at 7:30 AM, Linus Torvalds <[email protected]> wrote: > > On Apr 10, 2016 21:09, "Miika Turkia" <[email protected]> wrote: >> >> When importing the attached log file, the stable releases crash. I >> have not been able to figure out what is wrong (apart from apparent >> memory corruption). This seems to work on development version, but >> fails on the stable releases. Moreover, when I dump the imported log >> to a file before the crash, this log file opens up just fine. > > So I found a buglet in copy_dive() when I was doing the git save > optimization, and fixed that there - when copying the first dc (the one that > is part of the struct dive) we wouldn't do the proper strdup() of the dc > model name. But when I looked at it, I decided it couldn't matter, because > we never free the fields of the first dc anyway. > > But you do have copy_dive in your stack trace. Hmm.. > > The fix was to replace the open-coded sample/event copy calls after the > STRUCTURED_COPY_LIST() thing with a > > copy_dc(&s->dc, &d->dc); > > before that STRUCTURED_COPY_LIST(), so that we copy the first dive computer > and then copy the list of secondary computers after that. > > It mattered for my git save optimizations because my first version of that > also needed to invalidate the dc git cache when it did the copy. That never > made it to the final version, but the fix for copying the dc did. And you do > mention that the development version doesn't have this problem..
Seems that you were right about this (even though deciphering the instructions took a while :D) The attached patch works on my tests with the problematic input. It is against v4.5-branch. > Have you tried running things under valgrind? That tends to be very good at > finding memory corruption bugs. Unfortunately valgrind does not work with Subsurface nowadays. At least i crashes on my system when I try to run it. I have only been able to use it by writing a minimalistic test case for a feature and running valgrind against that. miika
From d5ce37a3f54738a8c43dd52ffecf859f20d92cf4 Mon Sep 17 00:00:00 2001 From: Miika Turkia <[email protected]> Date: Mon, 11 Apr 2016 21:00:59 +0300 Subject: [PATCH] Fix a crash on Seabear import Based on Linus' instructions on mailing list on how he fixed this bug when doing git save optimizations (as his fix never made it to the final version). Signed-off-by: Miika Turkia <[email protected]> --- dive.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dive.c b/dive.c index 83ec161..9401915 100644 --- a/dive.c +++ b/dive.c @@ -474,11 +474,13 @@ void copy_dive(struct dive *s, struct dive *d) d->weightsystem[i].description = copy_string(s->weightsystem[i].description); STRUCTURED_LIST_COPY(struct picture, s->picture_list, d->picture_list, copy_pl); STRUCTURED_LIST_COPY(struct tag_entry, s->tag_list, d->tag_list, copy_tl); - STRUCTURED_LIST_COPY(struct divecomputer, s->dc.next, d->dc.next, copy_dc); - /* this only copied dive computers 2 and up. The first dive computer is part - * of the struct dive, so let's make copies of its samples and events */ + + /* First copy the samples and events from first DC as those are + * part of the struct dive. Then copy the rest of the DCs. */ + copy_samples(&s->dc, &d->dc); copy_events(&s->dc, &d->dc); + STRUCTURED_LIST_COPY(struct divecomputer, s->dc.next, d->dc.next, copy_dc); } /* make a clone of the source dive and clean out the source dive; -- 2.5.0
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
