WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
39704
readPixels with negative width/height should generate INVALID_VALUE and return
https://bugs.webkit.org/show_bug.cgi?id=39704
Summary
readPixels with negative width/height should generate INVALID_VALUE and return
Zhenyao Mo
Reported
2010-05-25 17:54:00 PDT
Currently readPixels will crash if width/height are negative. Instead, INVALID_VALUE should be generated.
Attachments
patch
(11.06 KB, patch)
2010-05-25 19:20 PDT
,
Zhenyao Mo
no flags
Details
Formatted Diff
Diff
patch
(9.72 KB, patch)
2010-06-10 15:28 PDT
,
Zhenyao Mo
no flags
Details
Formatted Diff
Diff
revised patch: responding to kbr's review
(10.56 KB, patch)
2010-06-10 17:50 PDT
,
Zhenyao Mo
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Zhenyao Mo
Comment 1
2010-05-25 17:58:27 PDT
Also, with very large width/height and WebGL*Array creation failure, a INVALID_VALUE error will generate.
Zhenyao Mo
Comment 2
2010-05-25 19:20:04 PDT
Created
attachment 57063
[details]
patch
David Levin
Comment 3
2010-05-26 14:15:37 PDT
What bug is this new line fixing? 1707 memset(data, 0, totalBytes); And does the layout test cover that? (If not, can it be added?)
Zhenyao Mo
Comment 4
2010-05-26 14:34:56 PDT
(In reply to
comment #3
)
> What bug is this new line fixing? > > 1707 memset(data, 0, totalBytes); > > And does the layout test cover that? (If not, can it be added?)
This is not a bug fix. For safety reason, we clear the buffer so users will not get access to content they should not. According to GLES spec, for the un-covered portion of the memory, their content is un-defined. I don't think we should write a definitive test against something undefined, because whatever the content is, it should not be "incorrect".
David Levin
Comment 5
2010-05-26 14:40:14 PDT
(In reply to
comment #4
)
> (In reply to
comment #3
) > > What bug is this new line fixing? > > > > 1707 memset(data, 0, totalBytes); > > > > And does the layout test cover that? (If not, can it be added?) > > This is not a bug fix. For safety reason, we clear the buffer so users will not get access to content they should not. According to GLES spec, for the un-covered portion of the memory, their content is un-defined. I don't think we should write a definitive test against something undefined, because whatever the content is, it should not be "incorrect".
Should it be set to something (like -10 for example) that is less likely to make users rely on undefined behavior? 0 tends to make things just work (that maybe shouldn't) and thus hide problems.
Oliver Hunt
Comment 6
2010-05-26 14:41:19 PDT
(In reply to
comment #4
)
> (In reply to
comment #3
) > > What bug is this new line fixing? > > > > 1707 memset(data, 0, totalBytes); > > > > And does the layout test cover that? (If not, can it be added?) > > This is not a bug fix. For safety reason, we clear the buffer so users will not get access to content they should not. According to GLES spec, for the un-covered portion of the memory, their content is un-defined. I don't think we should write a definitive test against something undefined, because whatever the content is, it should not be "incorrect".
There should be a test, otherwise there's nothing to verify that the data is safe -- if some other implementation decides to produces something other than a zero-filled buffer they can add platform specific expected results.
Zhenyao Mo
Comment 7
2010-05-26 14:51:15 PDT
(In reply to
comment #5
)
> (In reply to
comment #4
) > > (In reply to
comment #3
) > > > What bug is this new line fixing? > > > > > > 1707 memset(data, 0, totalBytes); > > > > > > And does the layout test cover that? (If not, can it be added?) > > > > This is not a bug fix. For safety reason, we clear the buffer so users will not get access to content they should not. According to GLES spec, for the un-covered portion of the memory, their content is un-defined. I don't think we should write a definitive test against something undefined, because whatever the content is, it should not be "incorrect". > > Should it be set to something (like -10 for example) that is less likely to make users rely on undefined behavior? > > 0 tends to make things just work (that maybe shouldn't) and thus hide problems.
Good point. I'll double check WebGL spec, if it doesn't have extra constraints about buffers initialized to 0, I'll use an odd number instead.
Zhenyao Mo
Comment 8
2010-05-26 14:51:57 PDT
(In reply to
comment #6
)
> (In reply to
comment #4
) > > (In reply to
comment #3
) > > > What bug is this new line fixing? > > > > > > 1707 memset(data, 0, totalBytes); > > > > > > And does the layout test cover that? (If not, can it be added?) > > > > This is not a bug fix. For safety reason, we clear the buffer so users will not get access to content they should not. According to GLES spec, for the un-covered portion of the memory, their content is un-defined. I don't think we should write a definitive test against something undefined, because whatever the content is, it should not be "incorrect". > > > There should be a test, otherwise there's nothing to verify that the data is safe -- if some other implementation decides to produces something other than a zero-filled buffer they can add platform specific expected results.
Ok, will add a case then.
Zhenyao Mo
Comment 9
2010-05-26 15:07:44 PDT
ReadPixels signature will change. This patch becomes invalid.
Zhenyao Mo
Comment 10
2010-06-10 15:24:25 PDT
Due to
https://bugs.webkit.org/show_bug.cgi?id=40322
, negative width/height will no longer cause crash, but still, we need to deal with it correctly, i.e., generate INVALID_VALUE and return.
Zhenyao Mo
Comment 11
2010-06-10 15:28:01 PDT
Created
attachment 58418
[details]
patch
Kenneth Russell
Comment 12
2010-06-10 17:30:58 PDT
Comment on
attachment 58418
[details]
patch WebCore/html/canvas/WebGLRenderingContext.cpp:1673 + } Let's put this check right after the NULL check for the "pixels" argument tomorrow to try to follow the request for prioritization of error returns from Mozilla:
https://www.khronos.org/webgl/public-mailing-list/archives/1006/msg00040.html
LayoutTests/fast/canvas/webgl/read-pixels.html:184 + return; Should presumably say: } else if (!array.length) { shouldBe("gl.getError()", "gl.NO_ERROR"); return; }
Zhenyao Mo
Comment 13
2010-06-10 17:50:57 PDT
Created
attachment 58426
[details]
revised patch: responding to kbr's review
Kenneth Russell
Comment 14
2010-06-10 17:55:24 PDT
Comment on
attachment 58426
[details]
revised patch: responding to kbr's review Looks good.
Dimitri Glazkov (Google)
Comment 15
2010-06-10 21:34:21 PDT
Comment on
attachment 58426
[details]
revised patch: responding to kbr's review Make it so.
WebKit Commit Bot
Comment 16
2010-06-11 08:03:46 PDT
Comment on
attachment 58426
[details]
revised patch: responding to kbr's review Clearing flags on attachment: 58426 Committed
r61019
: <
http://trac.webkit.org/changeset/61019
>
WebKit Commit Bot
Comment 17
2010-06-11 08:03:52 PDT
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug