Bug 49350 - bufferData/bufferSubData should not crash with null data input
Summary: bufferData/bufferSubData should not crash with null data input
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGL (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Zhenyao Mo
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-10 16:14 PST by Zhenyao Mo
Modified: 2010-11-11 16:02 PST (History)
3 users (show)

See Also:


Attachments
patch (5.19 KB, patch)
2010-11-10 16:46 PST, Zhenyao Mo
kbr: review-
zmo: commit-queue-
Details | Formatted Diff | Diff
revised patch: responding to spec change (5.53 KB, patch)
2010-11-11 14:18 PST, Zhenyao Mo
kbr: review-
zmo: commit-queue-
Details | Formatted Diff | Diff
revised patch (5.29 KB, patch)
2010-11-11 15:36 PST, Zhenyao Mo
kbr: review+
zmo: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zhenyao Mo 2010-11-10 16:14:53 PST
Currently it will crash in command buffer port
Comment 1 Zhenyao Mo 2010-11-10 16:46:45 PST
Created attachment 73557 [details]
patch
Comment 2 Zhenyao Mo 2010-11-10 16:47:11 PST
Test synced with khronos
Comment 3 Kenneth Russell 2010-11-11 13:46:35 PST
Comment on attachment 73557 [details]
patch

Unfortunately the spec is badly written in this area, in particular for bufferData. I don't think that making the call a no-op is the right thing to do. I've just committed an update to the spec requiring that INVALID_VALUE is raised if bufferData is called with a null ArrayBuffer or ArrayBufferView. Could you please update the code and test? Thanks.
Comment 4 Zhenyao Mo 2010-11-11 14:18:06 PST
Created attachment 73660 [details]
revised patch: responding to spec change
Comment 5 Darin Adler 2010-11-11 14:21:06 PST
Comment on attachment 73660 [details]
revised patch: responding to spec change

You added four different places that return INVALID_VALUE. But you only have two test cases that expect INVALID_VALUE. That means that at least two of the code paths are untested. Could you fill out the tests?
Comment 6 Zhenyao Mo 2010-11-11 14:29:38 PST
I don't think we can, because when we pass in null, there is no way to tell it is ArrayBuffer null or ArrayBufferView null.
Comment 7 Kenneth Russell 2010-11-11 14:40:28 PST
Comment on attachment 73660 [details]
revised patch: responding to spec change

View in context: https://bugs.webkit.org/attachment.cgi?id=73660&action=review

> WebCore/html/canvas/WebGLRenderingContext.cpp:475
> +    if (!data) {
> +        m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
> +        return;
> +    }

The bufferSubData variants shouldn't generate INVALID_VALUE, only the bufferData variants. The bufferSubData variants can safely return early.

> WebCore/html/canvas/WebGLRenderingContext.cpp:498
> +    if (!data) {
> +        m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
> +        return;
> +    }

See above.

> LayoutTests/fast/canvas/webgl/buffer-data-array-buffer.html:26
> +glErrorShouldBe(gl, gl.INVALID_OPERATION);

Unfortunately per discussion on the public_webgl list I do not think we can mandate this behavior in the Khronos conformance suite. The overloading behavior in Web IDL is ambiguous in this case (http://dev.w3.org/2006/webapi/WebIDL/Overview.html#call) and Firefox does something different than WebKit. You could require that the GL error is either INVALID_OPERATION or NO_ERROR (and, implicitly, not a crash).
Comment 8 Zhenyao Mo 2010-11-11 15:36:04 PST
Created attachment 73673 [details]
revised patch
Comment 9 Kenneth Russell 2010-11-11 15:50:05 PST
Comment on attachment 73673 [details]
revised patch

View in context: https://bugs.webkit.org/attachment.cgi?id=73673&action=review

Looks fine; could you please add one comment to the test while landing?

> LayoutTests/fast/canvas/webgl/buffer-data-array-buffer.html:32
> +gl.bufferData(gl.ARRAY_BUFFER, null, gl.STATIC_DRAW);
> +gl.getError();

Could you add a comment like "this should not crash, but the selection of the overload is ambiguous per Web IDL"?
Comment 10 Zhenyao Mo 2010-11-11 15:56:44 PST
(In reply to comment #9)
> (From update of attachment 73673 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=73673&action=review
> 
> Looks fine; could you please add one comment to the test while landing?
> 
> > LayoutTests/fast/canvas/webgl/buffer-data-array-buffer.html:32
> > +gl.bufferData(gl.ARRAY_BUFFER, null, gl.STATIC_DRAW);
> > +gl.getError();
> 
> Could you add a comment like "this should not crash, but the selection of the overload is ambiguous per Web IDL"?

Will do.
Comment 11 Zhenyao Mo 2010-11-11 16:02:45 PST
Committed r71861: <http://trac.webkit.org/changeset/71861>