On Thu, 16 Sep 2004 16:31:30 +0300 (IDT)
Stanislav Malyshev <stas@zend.com> wrote:
> AD>>> class tables are already cleaned, etc.) - so it crashes.
> AD>>
> AD>>Looks like you're right, but why others can't reproduce this
> AD>segfault?
>
> Only idea I have they didn't run it in debug mode. In the debug mode,
> destroyed memory is overwritten, in the release mode it isn't. So on
> debug, use-after-free cases drop dead instantly, while on release mode
> they may very well work in some cases.
Ok, I got it.
> AD>>Sounds nice: we should not call destructors after they were
> AD>>already called =)
>
> The problem is that if one of the dtors fails, others aren't called.
> THis is OK (i.e., this is better than the alternatives), but it
> confuses the engine later on the way of shutdown.
Surely I agree.
> AD>>I could propose a simple solution: add a global flag, which will
> AD>indicate>that shutdown_destructors() was called, and do appropriate
> AD>check in>zend_objects_store_del_ref().
> AD>>Comments/objections?
>
> I personally don't like the idea of having yet another hack flag.
> Moveover, the del_ref is not the only place one may call destructors.
> What I'd do is: if one of the dtors bails out, we catch it in
> call_dtors and then mark all the objects as "already destroyed" - so
> there's no way any dtor could be called after that from any place.
> This is a bit slower performance-wise, bnut I'm not sure performance
> is much of concern in situation where the code has failed in shutdown
> - I don't know any "fast failure" benchmarks ;) After all, it will be
> not much longer than the regular shutdown anyway - one pass over the
> store. The advantage of this approach is that it follows the existing
> protocol and not insterts another flag (read - branch in any function
> working along the protocol) which leads to potential breakage.
Sounds quite nice.
Will look at it later a bit.
--
Wbr,
Antony Dovgal aka tony2001
tony2001@phpclub.net || antony@dovgal.com