View Issue Details

IDProjectCategoryView StatusLast Update
0001287ardourbugspublic2008-11-20 23:47
Reporterbrianahr Assigned Totaybin  
PrioritynormalSeveritycrashReproducibilityalways
Status closedResolutionfixed 
OSLinuxOS VersionGentoo 
Summary0001287: Crash due to bad delete[]
Descriptionafter the recent update from r1062 to 1065, ardour now crashes due to a delete on uninitialized memory.
Steps To Reproducestart ardour from a terminal
new session
exit ardour
'Segmentation fault' appears in the terminal.
Additional InformationI compiled with DEBUG=1, and ran it through GDB. it appears that the problem is here:

(gdb) frame 3
#3 0xb7ebf191 in ~SndFileSource (this=0x8c2b778) at libs/ardour/sndfilesource.cc:300
300 delete [] xfade_buf;

basically, it looks like in non-destructive mode, xfade_buf is deleted but never instantiated and/or initialized. for suggested fix, see patch.

TagsNo tags attached.

Activities

2006-11-03 04:00

 

ardour-r1065-seg-fix.patch (580 bytes)   
Index: libs/ardour/sndfilesource.cc
===================================================================
--- libs/ardour/sndfilesource.cc        (revision 1065)
+++ libs/ardour/sndfilesource.cc        (working copy)
@@ -213,7 +213,9 @@
        if (destructive()) {
                xfade_buf = new Sample[xfade_frames];
                timeline_position = header_position_offset;
-       }
+       } else {
+               xfade_buf = NULL;
+       }

        AudioFileSource::HeaderPositionOffsetChanged.connect (mem_fun (*this, &SndFileSource::handle_header_position_change));
 }
ardour-r1065-seg-fix.patch (580 bytes)   

brianahr

2006-11-03 04:14

developer   ~0002612

one other thing i forgot to mention (which I found while looking for this, and seems to be a related memory leak): in libs/ardour/destructive_filesource.cc

it looks like

DestructiveFileSource::~DestructiveFileSource()
{
    delete xfade_buf;
}

should be

DestructiveFileSource::~DestructiveFileSource()
{
    delete [] xfade_buf;
}

since xfade_buf is instantiated as Sample *xfade_buf = new Sample[xfade_frames];

taybin

2006-11-03 04:20

administrator   ~0002613

Last edited: 2006-11-03 04:22

Good catch. Thanks.

I've slightly reworked it though. Just a style thing. I put the xfade_buf = 0 at the top with the other _buf initialzations.

taybin

2006-11-03 04:23

administrator   ~0002614

I think the delete [] thing was caught already as of 1065.

taybin

2006-11-03 04:24

administrator   ~0002615

Thanks for the patches. Keep 'em coming! :)

Issue History

Date Modified Username Field Change
2006-11-03 04:00 brianahr New Issue
2006-11-03 04:00 brianahr File Added: ardour-r1065-seg-fix.patch
2006-11-03 04:14 brianahr Note Added: 0002612
2006-11-03 04:20 taybin Note Added: 0002613
2006-11-03 04:22 taybin Note Edited: 0002613
2006-11-03 04:23 taybin Note Added: 0002614
2006-11-03 04:24 taybin Status new => resolved
2006-11-03 04:24 taybin Resolution open => fixed
2006-11-03 04:24 taybin Assigned To => taybin
2006-11-03 04:24 taybin Note Added: 0002615
2008-11-20 23:47 seablade Status resolved => closed