On Fri, Feb 01, 2008 at 08:52:43PM +0100, Werner Smekal wrote: > Hi Torquil, > > I found the problem. Some months ago changes were made, how the plot > commands were recorded (into the memory instead of a file) to be able to > replot them. If the plot stream is copied with plcpstrm() also the > pointer to this memory is copied (not the memory itself). if you end the > copied stream this buffer gets freed. if the first stream is ended, the > buffer gets freed the second time->segfault. I didn't write this memory > buffer changes, so I don't know if we need the buffer in the new stream, > but if it needs to be copied, I suggest that new memory is allocated and > the whole memory is copied instead (I also post this to the devel list). > Any objections? > > Regards, > Werner > > PS: Thanks Torquil for finding this bug.
Werner, I've just been looking at this bug too. We need the buffer - this is what contains the copy of the plot commands for plreplot. The question is should the copied stream have a copy of the buffer, or the actual buffer. The old file buffer code seems to have used the actual file - so by analogy we should have the actual buffer. If this is the case, then we to have a reference counter for the buffer so we only free it once all streams no longer reference it. The original buffer code goes way back before my time with plplot. Does anyone still remember the original intentions? Alan might recall. I'll leave any fix to you so we don't duplicate work. Andrew P.S. I notice plstrm.h contains a plBufOwner variable to mark which stream actually owns a buffer. Unfortunately this isn't used. It also doesn't replace the reference counter because it doesn't stop a copy accessing the buffer after it has been free'd. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Plplot-general mailing list Plplot-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-general