[ale] C++ Debuggery and the Path of Destruction

John Mills johnmills at speakeasy.net
Fri Sep 24 21:28:23 EDT 2004


Barry -

Thanks for the input.

On Fri, 24 Sep 2004, Barry Rountree wrote:

> On Friday 24 September 2004 08:41 pm, John Mills wrote:
> > Naturally, I got a bit too clever 
 
> It's almost certainly going to be easier to rewrite it as something less 
> clever, but hey, where's the fun in that?

Yes, well there is that aspect. I've been at this long enough to know I'm 
creating a maintenance headache, though, and less clever would be smarter.

The ostensible reason is I am allocating image buffers that are passed on
to an unknown number of asynchronous clients. I store them in a ring that
[hopefully] has enough slots so even a slow client will have time to send
the newest buffer before it is trashed in favor of a yet newer image (4 or
5 down the line). That code is very simple and works fine. The alternative
seemed to be copying each buffer for each client to which it's due, which
I wanted to avoid.

> Any chance of posting some code?

I will if I come up with a simple example. Right now the mechanics obscure
the problem - even for the benighted author. &8-)

> You can also try zeroing out the object's memory during destruction -- that 
> might let you segfault a bit sooner at a more useful location.  

Sounds like a useful idea, and easy to do.

> Combine the two and you should see an object getting freed that is later 
> referenced.  

Good point.

Thanks.

 - John Mills
   john.m.mills at alum.mit.edu



More information about the Ale mailing list