Bug 177603 - Use smart pointers for creating, adding and removing renderers
Summary: Use smart pointers for creating, adding and removing renderers
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-09-28 07:29 PDT by Antti Koivisto
Modified: 2017-09-29 23:46 PDT (History)
7 users (show)

See Also:


Attachments
patch (136.44 KB, patch)
2017-09-28 07:30 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (136.42 KB, patch)
2017-09-28 07:52 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (136.04 KB, patch)
2017-09-29 02:07 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff
patch (146.39 KB, patch)
2017-09-29 06:51 PDT, Antti Koivisto
zalan: review+
commit-queue: commit-queue-
Details | Formatted Diff | Diff
patch (146.29 KB, patch)
2017-09-29 23:05 PDT, Antti Koivisto
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Koivisto 2017-09-28 07:29:36 PDT
RenderPtr everywhere.
Comment 1 Antti Koivisto 2017-09-28 07:30:01 PDT
Created attachment 322080 [details]
patch
Comment 2 Antti Koivisto 2017-09-28 07:52:25 PDT
Created attachment 322083 [details]
patch
Comment 3 Brent Fulgham 2017-09-28 09:01:55 PDT
Yes, please! :-)
Comment 4 zalan 2017-09-28 10:11:25 PDT
Comment on attachment 322083 [details]
patch

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

> Source/WebCore/rendering/RenderBlock.cpp:815
> +    auto toBeDeleted = parent.removeChildInternal(child, child.hasLayer() ? NotifyChildren : DontNotifyChildren);

I am a bit worried about the potential UAF errors this introduces. (takeInternal might make it less error prone)

...
RenderObject* nextSibling = child.nextSibling();
...
// We need to scope here because of reasons.
{
    reasonForScoping();
    ...
    parent.removeChildInternal(child);
    ...
}
child.deleteLines();

> Source/WebCore/rendering/RenderGrid.cpp:71
> +    auto& child = baseAddChild<RenderBlock>(WTFMove(newChild), beforeChild);

I wish there was a better way to write this. I am sure we'll see problems like the moved newChild used later accidentally (I know this is a general problem, the only reason I am picking on this is because newChild is an argument). I've run into problems like this in the past.
Comment 5 Antti Koivisto 2017-09-28 13:42:25 PDT
> I am a bit worried about the potential UAF errors this introduces.
> (takeInternal might make it less error prone)

One thing we can do is to use an annotation to make compiler warns on unused return value.
Comment 6 zalan 2017-09-28 13:43:19 PDT
(In reply to Antti Koivisto from comment #5)
> > I am a bit worried about the potential UAF errors this introduces.
> > (takeInternal might make it less error prone)
> 
> One thing we can do is to use an annotation to make compiler warns on unused
> return value.
Yeah, that's a good idea.
Comment 7 Antti Koivisto 2017-09-29 02:07:21 PDT
Created attachment 322181 [details]
patch
Comment 8 Antti Koivisto 2017-09-29 06:51:23 PDT
Created attachment 322182 [details]
patch
Comment 9 Radar WebKit Bug Importer 2017-09-29 10:48:24 PDT
<rdar://problem/34742406>
Comment 10 WebKit Commit Bot 2017-09-29 10:51:39 PDT
Comment on attachment 322182 [details]
patch

Rejecting attachment 322182 [details] from commit-queue.

Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-01', 'apply-attachment', '--no-update', '--non-interactive', 322182, '--port=mac']" exit_code: 2 cwd: /Volumes/Data/EWS/WebKit

Last 500 characters of output:
eePosition.h
patching file Source/WebCore/style/RenderTreeUpdater.cpp
patching file Source/WebCore/style/RenderTreeUpdaterFirstLetter.cpp
patching file Source/WebCore/style/RenderTreeUpdaterGeneratedContent.cpp
patching file Source/WebCore/style/RenderTreeUpdaterListItem.cpp
patching file Source/WebCore/style/RenderTreeUpdaterMultiColumn.cpp

Failed to run "[u'/Volumes/Data/EWS/WebKit/Tools/Scripts/svn-apply', '--force', '--reviewer', u'Zalan Bujtas']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit

Full output: http://webkit-queues.webkit.org/results/4699618
Comment 11 Antti Koivisto 2017-09-29 23:05:47 PDT
Created attachment 322283 [details]
patch
Comment 12 WebKit Commit Bot 2017-09-29 23:46:04 PDT
Comment on attachment 322283 [details]
patch

Clearing flags on attachment: 322283

Committed r222679: <http://trac.webkit.org/changeset/222679>
Comment 13 WebKit Commit Bot 2017-09-29 23:46:06 PDT
All reviewed patches have been landed.  Closing bug.