Hi,

The bug report about fastMalloc(0):
https://bugs.webkit.org/show_bug.cgi?id=55097

Brewmp had conditions for fastMalloc(0) earlier, but it was removed in:
http://trac.webkit.org/changeset/95555/trunk/Source/JavaScriptCore/wtf/FastMalloc.cpp

Cheers,
<Zoltan>

On Wed, 13 Jun 2012 00:08:48 +0200, Adam Barth <[email protected]> wrote:

There was some discussion about how to handle malloc(0) a year or so
ago.  I don't remember if it was on webkit-dev, but you might want to
check the archives.  Eric Seidel might remember what conclusions (if
any) we came to.

Adam


On Tue, Jun 12, 2012 at 3:03 PM, Myles C. Maxfield
<[email protected]> wrote:
Hello,
I'm compiling WebKit with a malloc() implementation that returns NULL
for malloc(0). According to C99, this is valid: "If the size of the
space requested is zero, the behavior is implementation- defined:
either a null pointer is returned, or the behavior is as if the size
were some nonzero value, except that the returned pointer shall not be
used to access an object."

I noticed that this caused a problem in one particular place
(WTF::StringImpl::getData16SlowCase()) where the code allocates
(constant * length) bytes for an (empty) string, and provides an
accessor that exposes this pointer. This pointer was being passed to
ICU, which didn't perform the requested function because it looked
like one of the arguments was invalid, even though it was just empty.

I have worked around this one particular occurrence in my local
version of WebKit fork, but I'm wondering how often this pattern
occurs. Is my fix worth upstreaming?  Is it worth trying to find,
"fix," and upstream every occurrence of this pattern? Or is this
particular behavior of malloc() an unstated requirement of building
WebKit? If the latter is true, perhaps it's worth explicitly stating
this somewhere? What is the opinion of the community?

Thanks,
Myles
_______________________________________________
webkit-dev mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
_______________________________________________
webkit-dev mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
_______________________________________________
webkit-dev mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

Reply via email to