|
Boost Users : |
Subject: [Boost-users] Preventing iostreams from accessing freed memory
From: Adam Nielsen (a.nielsen_at_[hidden])
Date: 2011-03-12 21:49:42
Hi all,
I'm unable to prevent Boost iostreams from accessing memory once it has been
freed, and I'm hoping someone here familiar with iostreams has some advice.
As far as I can tell, when I push a standard iostream onto a filter, the
filter holds on to a reference of it. If this happens inside a function, then
when the function returns the iostream is freed, followed by the filter. In
its destructor the filter tries to perform a flush/close and promptly
segfaults, as it is trying to access the iostream which has just been freed.
There is a set_auto_close() function I can call on the filter which sounds
like it would do the trick, but it doesn't and according to the docs it's
because it "does not prevent the Filters and Devices in the chain from being
closed [flushed] automatically if the chain is complete at destruction."
So is there any way I can prevent a filtering_stream from performing I/O in
its destructor?
Thanks,
Adam.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net