Bug 74965 - [Coverity] Fix uninitialized constructor defects in .../html
Summary: [Coverity] Fix uninitialized constructor defects in .../html
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Greg Billock
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-20 15:21 PST by Greg Billock
Modified: 2012-01-19 15:47 PST (History)
12 users (show)

See Also:


Attachments
Patch (9.25 KB, patch)
2011-12-20 15:22 PST, Greg Billock
no flags Details | Formatted Diff | Diff
Patch (10.04 KB, patch)
2011-12-20 16:25 PST, Greg Billock
no flags Details | Formatted Diff | Diff
Patch (10.04 KB, patch)
2011-12-21 10:24 PST, Greg Billock
no flags Details | Formatted Diff | Diff
Patch (10.10 KB, patch)
2012-01-03 13:14 PST, Greg Billock
no flags Details | Formatted Diff | Diff
Patch (9.37 KB, patch)
2012-01-04 15:00 PST, Greg Billock
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Billock 2011-12-20 15:21:52 PST
[Coverity] Fix uninitialized constructor defects in .../html
Comment 1 Greg Billock 2011-12-20 15:22:58 PST
Created attachment 120097 [details]
Patch
Comment 2 Adam Barth 2011-12-20 15:59:20 PST
Comment on attachment 120097 [details]
Patch

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

> Source/WebCore/html/HTMLFormCollection.cpp:48
>      : HTMLCollection(form.get(), OtherCollection, formCollectionInfo(form.get()))
> +    , currentPos(0)

Can you reformat this initializer list to the usual WebKit style (which is to start each line after the first with a ",") ?

> Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp:222
> +    , m_lineDashOffset(other.m_lineDashOffset)

Is this change testable?
Comment 3 Greg Billock 2011-12-20 16:22:47 PST
Comment on attachment 120097 [details]
Patch

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

>> Source/WebCore/html/HTMLFormCollection.cpp:48
>> +    , currentPos(0)
> 
> Can you reformat this initializer list to the usual WebKit style (which is to start each line after the first with a ",") ?

Do you mean put the superclass constructor call on the previous line?

>> Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp:222
>> +    , m_lineDashOffset(other.m_lineDashOffset)
> 
> Is this change testable?

I think so. This code gets exercised in save(), which is called by clearRect(). I added a clearRect call to the layout test to ensure that the value is preserved.
Comment 4 Greg Billock 2011-12-20 16:25:27 PST
Created attachment 120110 [details]
Patch
Comment 5 Alexey Proskuryakov 2011-12-20 16:48:10 PST
Comment on attachment 120110 [details]
Patch

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

It's great that Coverity found a real bug. We shouldn't take any complaint it makes as a requirement though. The changes in WebGLGetInfo look clearly against the intended design of this class.

> Source/WebCore/html/StepRange.cpp:42
> -    if (element->hasAttribute(precisionAttr)) {
> -        step = 1.0;
> +    step = 1.0;
> +    if (element->hasAttribute(precisionAttr))
>          hasStep = !equalIgnoringCase(element->getAttribute(precisionAttr), "float");
> -    } else
> +    else
>          hasStep = element->getAllowedValueStep(&step);

Is this change testable?

Although you're just moving this code, please note that WebKit coding style asks to not use .0 suffix on floating point literals. The same issue is present in some code you added below.

> Source/WebCore/html/canvas/CanvasStyle.h:91
> +            CMYKAValues() : c(0.0), m(0.0), y(0.0), k(0.0), a(0.0) { }

No .0, again.

> Source/WebCore/html/track/WebVTTParser.cpp:113
> +    , m_currentStartTime(0.0)
> +    , m_currentEndTime(0.0)

No .0.
Comment 6 Adam Barth 2011-12-20 16:54:23 PST
Comment on attachment 120097 [details]
Patch

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

>>> Source/WebCore/html/HTMLFormCollection.cpp:48
>>> +    , currentPos(0)
>> 
>> Can you reformat this initializer list to the usual WebKit style (which is to start each line after the first with a ",") ?
> 
> Do you mean put the superclass constructor call on the previous line?

Oh, I misread the code that was already there.  Please ignore my comment.
Comment 7 Greg Billock 2011-12-21 10:23:23 PST
Comment on attachment 120110 [details]
Patch

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

>> Source/WebCore/html/StepRange.cpp:42
>>          hasStep = element->getAllowedValueStep(&step);
> 
> Is this change testable?
> 
> Although you're just moving this code, please note that WebKit coding style asks to not use .0 suffix on floating point literals. The same issue is present in some code you added below.

Done.

I don't think this change is visible in tests. Coverity is worried that element->getAllowedValueStep may not initialize |step|, leaving the class in an undefined state. There's a check in clampValue accounting for that, so initializing is more of a cleanliness issue and insurance against regression.

>> Source/WebCore/html/canvas/CanvasStyle.h:91
>> +            CMYKAValues() : c(0.0), m(0.0), y(0.0), k(0.0), a(0.0) { }
> 
> No .0, again.

Done. (And elsewhere)

>> Source/WebCore/html/track/WebVTTParser.cpp:113
>> +    , m_currentEndTime(0.0)
> 
> No .0.

Done.
Comment 8 Greg Billock 2011-12-21 10:24:47 PST
Created attachment 120190 [details]
Patch
Comment 9 Darin Adler 2011-12-21 11:10:36 PST
Comment on attachment 120190 [details]
Patch

Many of these changes look like they make the tool happy by initializing data that will never be read. Is there a distinction between changes that are actually needed and ones that just quiet the tool?
Comment 10 Alexey Proskuryakov 2011-12-21 14:04:21 PST
Comment on attachment 120190 [details]
Patch

Thank you! The change in StepRange constructor seems somewhat arbitrary and fragile, but the benefit of making future runs of Coverity cleaner outweighs the cost of code churn in my opinion.

I'm still concerned by the changes to WebGLGetInfo. I think that these need to be discussed with an expert on this code (likely an author).
Comment 11 Alexey Proskuryakov 2011-12-21 14:06:34 PST
I think that all changes here are just to shut up the tool, except for the one that has a test. With the possible exception of WebGLGetInfo changes, these look harmless to me.
Comment 12 Greg Billock 2011-12-21 14:26:55 PST
Yes, the CanvasRenderingContext2D case is a real bug. I think the HTMLTreeBuilder and CSSPreloadScanner cases are oversights that's fair to call a hit as well. The rest are as you describe: nice to have the tool low-noise so real bugs like this stand out, and probably clearer on balance as well. I'm happy to get the WebGLInfo author to weigh in on those changes, since they are on the edge.
Comment 13 Alexey Proskuryakov 2011-12-21 14:56:59 PST
CC'ing folks who show up in svn blame for WebGLGetInfo.cpp
Comment 14 Kenneth Russell 2011-12-21 15:48:55 PST
Comment on attachment 120190 [details]
Patch

The changes to WebGLGetInfo look good.
Comment 15 Greg Billock 2011-12-22 12:39:02 PST
Good to go?
Comment 16 Greg Billock 2012-01-03 13:14:59 PST
Created attachment 120985 [details]
Patch
Comment 17 WebKit Review Bot 2012-01-03 13:18:30 PST
Attachment 120985 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/update-webkit']" exit_code: 9

Updating OpenSource
Index mismatch: 3a7674dadd24ecd6a1b023eba203ecf2ed62fc59 != edb861612940a3244431d239dacdbc36317b627c
rereading e1e2538cff7d320c2b7cc22c0b75c9369ce9cdb2
	A	LayoutTests/svg/custom/webkit-transform-crash.html
	A	LayoutTests/svg/custom/webkit-transform-crash-expected.txt
	M	LayoutTests/ChangeLog
	M	Source/WebCore/ChangeLog
	M	Source/WebCore/svg/SVGStyledTransformableElement.cpp
103950 = 8282a1d85ad097ce4064a5896912bdb211b115e6 already exists! Why are we refetching it?
 at /usr/lib/git-core/git-svn line 5210

Died at Tools/Scripts/update-webkit line 158.


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 18 Adam Barth 2012-01-03 13:24:18 PST
> 103950 = 8282a1d85ad097ce4064a5896912bdb211b115e6 already exists! Why are we refetching it?
>  at /usr/lib/git-core/git-svn line 5210

Sorry.  Will fix.
Comment 19 Gyuyoung Kim 2012-01-03 14:27:25 PST
Comment on attachment 120985 [details]
Patch

Attachment 120985 [details] did not pass efl-ews (efl):
Output: http://queues.webkit.org/results/11082160
Comment 20 WebKit Review Bot 2012-01-03 14:29:13 PST
Comment on attachment 120985 [details]
Patch

Attachment 120985 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/11083171
Comment 21 Collabora GTK+ EWS bot 2012-01-03 17:00:24 PST
Comment on attachment 120985 [details]
Patch

Attachment 120985 [details] did not pass gtk-ews (gtk):
Output: http://queues.webkit.org/results/11070201
Comment 22 Early Warning System Bot 2012-01-04 03:09:18 PST
Comment on attachment 120985 [details]
Patch

Attachment 120985 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/10954873
Comment 23 Greg Billock 2012-01-04 12:44:00 PST
Were the bots misfiring on this patch? Or shall I resync and try again?
Comment 24 Adam Barth 2012-01-04 14:30:12 PST
Comment on attachment 120985 [details]
Patch

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

> Source/WebCore/html/parser/HTMLTreeBuilder.cpp:357
> +    , m_isFakeInsertionMode(false)

This variable does not exist anymore, which is what's causing the build break.
Comment 25 Greg Billock 2012-01-04 14:59:48 PST
Comment on attachment 120985 [details]
Patch

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

>> Source/WebCore/html/parser/HTMLTreeBuilder.cpp:357
>> +    , m_isFakeInsertionMode(false)
> 
> This variable does not exist anymore, which is what's causing the build break.

drat, thanks. I saw the sync errors and thought it was a technicality.
Comment 26 Greg Billock 2012-01-04 15:00:45 PST
Created attachment 121164 [details]
Patch
Comment 27 Greg Billock 2012-01-05 15:15:48 PST
Now fixed.
Comment 28 Greg Billock 2012-01-19 15:21:27 PST
Can you send this into the commit queue? Or do I need to merge to head at this point? Thanks!
Comment 29 Alexey Proskuryakov 2012-01-19 15:29:51 PST
Comment on attachment 121164 [details]
Patch

We'll see if it still applies.
Comment 30 WebKit Review Bot 2012-01-19 15:47:46 PST
Comment on attachment 121164 [details]
Patch

Clearing flags on attachment: 121164

Committed r105457: <http://trac.webkit.org/changeset/105457>
Comment 31 WebKit Review Bot 2012-01-19 15:47:53 PST
All reviewed patches have been landed.  Closing bug.