Re: [PHP-DEV] [PATCH] Zend/zend_alloc.c From: Walter Franzini (walter <email protected>)
Date: 08/29/01

Zeev Suraski <zeev <email protected>> 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 <email protected>
SysNet, Via Digione 8, 27100 Pavia - Italy

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>