Csound Csound-dev Csound-tekno Search About

[Csnd] tracking segmentation faults / memory allocation

Date2005-08-20 11:56
FromSimon Schampijer
Subject[Csnd] tracking segmentation faults / memory allocation
Hi,
I wonder if there is a way of tracking down segmentation
faults reported by csound which I get during the development
of plugin opcodes. Csound tidy up: Segmentation fault
(I get them after the performance finishs correctly)
One thing that could cause the problem is memory allocation
which is  done by using the AUXCH structure. 

in the data structure: 
AUXCH buffer;
the init function:
if(p->buffer.auxp==NULL)
	csound->AuxAlloc(csound, buffersize*sizeof(MYFLT),
&p->buffer);
the process function:
After filling the buffer I call the draw method of my opengl
window class to display the buffer content. I use a pointer
(of the class)  to point on the memory. 
window->pbuffer = (MYFLT*)p->buffer.auxp;
Could this cause a problem? I tried with allocating the
memory in the constructor of the window class (i know that
this is not desired) and seem not to have the seg-faults.

Any Ideas? hints? 
Thanks in advance
Simon

-- 
Send bugs reports to this list.
To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk

Date2005-08-20 12:07
FromIstvan Varga
SubjectRe: [Csnd] tracking segmentation faults / memory allocation
Does your window class possibly use the buffer after the end of
performance (even if only by a small amount of time) ?
All memory allocated with AuxAlloc is automatically freed at
end of performance (and also at end of section).
Another possible error is if you change, reallocate, or free
the auxp pointer in an AUXCH structure in any way other than
calling AuxAlloc with a new size. In general, you should consider
the contents of the AUXCH structure read-only.

Simon Schampijer wrote:

> I wonder if there is a way of tracking down segmentation
> faults reported by csound which I get during the development
> of plugin opcodes. Csound tidy up: Segmentation fault
> (I get them after the performance finishs correctly)
> One thing that could cause the problem is memory allocation
> which is  done by using the AUXCH structure. 
> 
> in the data structure: 
> AUXCH buffer;
> the init function:
> if(p->buffer.auxp==NULL)
> 	csound->AuxAlloc(csound, buffersize*sizeof(MYFLT),
> &p->buffer);

Note that this is not safe if a new call of the opcode requests
a larger buffer size, assuming that the buffer size depends on
some parameter of the opcode and is not constant.
-- 
Send bugs reports to this list.
To unsubscribe, send email to csound-unsubscribe@lists.bath.ac.uk