Re: [PATCH] Zend/zend_alloc.c

From: Date: Wed, 29 Aug 2001 15:35:41 +0000
Subject: Re: [PATCH] Zend/zend_alloc.c
References: 1 2 3 4 5  Groups: php.dev 
Request: Send a blank email to php-dev+get-64628@lists.php.net to get a copy of this message
Zeev Suraski <zeev@zend.com> writes:

> At 14:57 29-08-01, Walter Franzini wrote:
> > From the extension (the user of kernel services) pov I must disagree.
>>But obviusly I'missing something :-)
>
> I don't see why there's a difference.

Maybe the difference is not ZE vs. extension but internal vs. external
data, where external means coming from the outside of PHP/Zend.

If you try to allocate memory for data that come from the outside (the
browser, a db) you should fail gracefully: a malicious user can send
to your app a huge amount of data only to make it crash.  

From the user point of view an application that exit without a message
is crashed, no matter how controlled the shutdown is.

Is this a reasonable scenario? 

[...]

> Do you have a case where you want to try and allocate a chunk of
> memory, and do something special in case it fails (e.g., allocate a
> smaller block)?  If so, we can try to come up with a solution.

No, at the moment I use PHP to write webApp and I really hate "the
document contains non data" message :-)

> My main point is that there's a very strong motivation to take away
> the responsibility of what happens in case of a memory failure away
> from the API user, and take care of it in a centralized way in the
> memory manager.  It's safer (no possibility of memory allocation
> failures causing crashes) and it avoids redundant coding.  If this
> behavior is unsuitable in certain cases, we should address these
> cases, rather than cut this safety net to pieces.

I really understand, and appreciate, your position, but I think that:

"Ehi, this stupid program want 2GB of memory and I only have 600MB
available.  It's time to exit!!"

is not the best reaction for the ZE.

But

"Ehi, I can't allocate the memory needed to store a refcount.  It's
time to exit!!"

seems reasonable to me.

>
> Zeev

Thank for your patience.

Ciao
-- 
Walter Franzini, e-mail: walter@sys-net.it
SysNet, Via Digione 8, 27100 Pavia - Italy



Thread (18 messages)

« previous php.dev (#64628) next »