Bug 119513 - [WebGL] compileShader map iterator validation
Summary: [WebGL] compileShader map iterator validation
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGL (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-06 00:41 PDT by Przemyslaw Szymanski
Modified: 2016-04-15 15:33 PDT (History)
8 users (show)

See Also:


Attachments
map iterator validation (1.75 KB, patch)
2013-08-06 00:43 PDT, Przemyslaw Szymanski
bfulgham: review-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Przemyslaw Szymanski 2013-08-06 00:41:10 PDT
There is a missing validation when it is read from the map. Iterators should always have to be checked if point to the end of the container.
Comment 1 Przemyslaw Szymanski 2013-08-06 00:43:57 PDT
Created attachment 208172 [details]
map iterator validation
Comment 2 Kalyan 2013-08-06 01:08:07 PDT
LGTM
Comment 3 Andreas Kling 2013-08-08 04:47:43 PDT
Comment on attachment 208172 [details]
map iterator validation

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

> Source/WebCore/ChangeLog:15
> +        No new tests. Covered by existing tests.
> +        LayoutTests/webgl/conformance/glsl/functions/glsl-function-abs.html
> +        LayoutTests/webgl/conformance/glsl/functions/glsl-function-acos.html
> +        LayoutTests/webgl/conformance/glsl/functions/glsl-function-length.html

These tests currently crash, or exhibit bad behavior?
If so, we should unskip them with this change.
Comment 4 Przemyslaw Szymanski 2013-08-08 06:14:24 PDT
(In reply to comment #3)
> (From update of attachment 208172 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=208172&action=review
> 
> > Source/WebCore/ChangeLog:15
> > +        No new tests. Covered by existing tests.
> > +        LayoutTests/webgl/conformance/glsl/functions/glsl-function-abs.html
> > +        LayoutTests/webgl/conformance/glsl/functions/glsl-function-acos.html
> > +        LayoutTests/webgl/conformance/glsl/functions/glsl-function-length.html
> 
> These tests currently crash, or exhibit bad behavior?
> If so, we should unskip them with this change.

Thank you for your review.
These tests works fine. I ran them in the minibrowser directly. I ran Khronos conformance tests too. This patch does not break any webgl test.
Comment 5 Andreas Kling 2013-08-08 06:51:02 PDT
(In reply to comment #4)
> (In reply to comment #3)
> > (From update of attachment 208172 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=208172&action=review
> > 
> > > Source/WebCore/ChangeLog:15
> > > +        No new tests. Covered by existing tests.
> > > +        LayoutTests/webgl/conformance/glsl/functions/glsl-function-abs.html
> > > +        LayoutTests/webgl/conformance/glsl/functions/glsl-function-acos.html
> > > +        LayoutTests/webgl/conformance/glsl/functions/glsl-function-length.html
> > 
> > These tests currently crash, or exhibit bad behavior?
> > If so, we should unskip them with this change.
> 
> Thank you for your review.
> These tests works fine. I ran them in the minibrowser directly. I ran Khronos conformance tests too. This patch does not break any webgl test.

If these tests work fine without the change, how is this "covered by existing tests"?
Comment 6 Antonio Gomes 2013-08-08 07:54:57 PDT
Comment on attachment 208172 [details]
map iterator validation

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

> Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:467
> +        if (result == m_shaderSourceMap.end())
> +            return;

what situation does the patch help?
Comment 7 Przemyslaw Szymanski 2013-08-08 22:39:24 PDT
(In reply to comment #6)
> (From update of attachment 208172 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=208172&action=review
> 
> > Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:467
> > +        if (result == m_shaderSourceMap.end())
> > +            return;
> 
> what situation does the patch help?

It avoids possibly bug/crash. Assume m_shaderSourceMap does not contain search object. Then result iterator will point to m_shaderSourceMap.end() and read from it should crash. 
Look in other methods with use of m_shaderSourceMap.find. There are that checks too. I think someone forgot about this check here.
Comment 8 Brent Fulgham 2014-01-10 10:33:15 PST
Comment on attachment 208172 [details]
map iterator validation

This patch isn't necessary (though it would be harmless).

We call "m_extensions->getTranslatedShaderSourceANGLE(shader)", which does it's own check of the m_shaderSourceMap, and returns an empty string if there is no shader source entry. We check for the empty string and return prior to hitting the point where you propose adding a check.

I don't think this change would actually be executed.