Raw std::auto_ptr use

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Mon, 28 Jun 2010 10:21:16 -0600

Hello,

    Bug #2964 fix uses <memory> and std::auto_ptr to prevent memory
leaks in the presence of C++ exceptions. This is a standard technique,
using standard code, but we have never used it in Squid. GCC and all
modern C++ compilers support auto_ptr. However, I suspect there are old
compilers or build environments that do not. Moreover, some modern C++
compilers may not support standard auto_ptr child-to-parent pointer
conversion (yet) and the fix uses them.

Our options include:

1. Use <memory> and std::auto_ptr as we use std::ostream. No wrappers or
checks. Refuse to support environments where this old and standard C++
feature is unavailable or broken. This allows us to commit bug #2964
fixes now and easily fix similar bugs in the future.

2. Use <memory> and std::auto_ptr if ./configure decides that we can.
Otherwise, provide wrappers/replacements. Please keep in mind that
auto_ptr is a rather tricky beast so providing a true replacement may be
difficult or not portable. It also obviously requires more work, and I
may not be able to promptly supply those wrappers/replacements, delaying
acceptance of the bug #2964 fix.

3. Use Boost that has similar classes with appropriate portability
wrappers. Boost has lots of other goodies, of course. Unfortunately,
Boost itself is a rather complicated monster that may not be easy to
integrate with. Also, a Boost dependency may be too big of a change for
Squid v3.1 and bug #2964 fix is needed there.

12. Do #1 now but promise eventual #2 availability to those affected by
auto_ptr portability. This means that a few affected will not be able to
upgrade their existing v3.1 installations for a while, but the majority
of folks will be happy. This option allows us to passively discover
auto_ptr portability problems instead of proactively spending cycles on
fixing or avoiding those problems.

How should we proceed?

Thank you,

Alex.

On 06/28/2010 07:53 AM, bugzilla-daemon_at_squid-cache.org wrote:
> http://bugs.squid-cache.org/show_bug.cgi?id=2964
>
> --- Comment #4 from Stefan Fritsch <sf_at_sfritsch.de> ---
> (In reply to comment #3)
>> The patch has been ported to but not tested on 3.1.4. Please test.
>
> Thanks again. I have done some testing together on top of the patches from bug
> #2583 and bug #2927. It works fine and I could not trigger any memory leaks,
> anymore.
>
> Will the patches be included in 3.1.5?
>
Received on Mon Jun 28 2010 - 16:22:04 MDT

This archive was generated by hypermail 2.2.0 : Mon Jun 28 2010 - 12:00:07 MDT