WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
146391
ResourceError should store failingURL as URL instead of String to avoid reparsing and to address FIXME comments in ResourceErrorCF.cpp and ResourceErrorMac.mm
https://bugs.webkit.org/show_bug.cgi?id=146391
Summary
ResourceError should store failingURL as URL instead of String to avoid repar...
David Kilzer (:ddkilzer)
Reported
2015-06-27 21:25:04 PDT
Address the FIXME comments added for the build for for
Bug 146384
: Committed
r186036
: <
http://trac.webkit.org/changeset/186036
>
Attachments
Patch v1
(3.07 KB, patch)
2015-06-27 21:36 PDT
,
David Kilzer (:ddkilzer)
no flags
Details
Formatted Diff
Diff
Patch v2
(3.27 KB, patch)
2015-12-22 20:25 PST
,
David Kilzer (:ddkilzer)
no flags
Details
Formatted Diff
Diff
Patch v3 (checking EFL/GTK builds)
(36.62 KB, patch)
2015-12-23 18:58 PST
,
David Kilzer (:ddkilzer)
no flags
Details
Formatted Diff
Diff
Patch v4
(38.06 KB, patch)
2015-12-23 19:27 PST
,
David Kilzer (:ddkilzer)
no flags
Details
Formatted Diff
Diff
Patch v5
(48.49 KB, patch)
2015-12-23 22:24 PST
,
David Kilzer (:ddkilzer)
no flags
Details
Formatted Diff
Diff
Patch v6
(52.77 KB, patch)
2015-12-23 22:49 PST
,
David Kilzer (:ddkilzer)
no flags
Details
Formatted Diff
Diff
Patch v7
(52.90 KB, patch)
2015-12-24 07:56 PST
,
David Kilzer (:ddkilzer)
no flags
Details
Formatted Diff
Diff
Patch v8
(52.91 KB, patch)
2015-12-24 08:06 PST
,
David Kilzer (:ddkilzer)
no flags
Details
Formatted Diff
Diff
Patch v9
(55.94 KB, patch)
2015-12-24 08:22 PST
,
David Kilzer (:ddkilzer)
no flags
Details
Formatted Diff
Diff
Patch v10
(56.79 KB, patch)
2015-12-24 08:34 PST
,
David Kilzer (:ddkilzer)
no flags
Details
Formatted Diff
Diff
Show Obsolete
(9)
View All
Add attachment
proposed patch, testcase, etc.
David Kilzer (:ddkilzer)
Comment 1
2015-06-27 21:36:53 PDT
Created
attachment 255717
[details]
Patch v1
Alexey Proskuryakov
Comment 2
2015-06-27 23:22:10 PDT
Comment on
attachment 255717
[details]
Patch v1 View in context:
https://bugs.webkit.org/attachment.cgi?id=255717&action=review
> Source/WebCore/platform/network/cf/ResourceErrorCF.cpp:157 > + if (RetainPtr<CFURLRef> url = URL(URL(), m_failingURL).createCFURL())
Can this be tested? As a general principle, I think that we shouldn't expose invalid URLs in API. The fact that the URL is invalid gets lost in conversion, and it's too easy for the client to make incorrect decisions based on the URL string. I can't find it now, but we even had security bugs caused by handling invalid URLs.
David Kilzer (:ddkilzer)
Comment 3
2015-06-28 01:02:45 PDT
(In reply to
comment #2
)
> Comment on
attachment 255717
[details]
> Patch v1 > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=255717&action=review
> > > Source/WebCore/platform/network/cf/ResourceErrorCF.cpp:157 > > + if (RetainPtr<CFURLRef> url = URL(URL(), m_failingURL).createCFURL()) > > Can this be tested?
It's not known how to reproduce the crash. Do you have ideas about how to reproduce it based on the crashing stack? Maybe setting the source of an iframe with an invalid URL?
Darin Adler
Comment 4
2015-06-28 11:12:45 PDT
Comment on
attachment 255717
[details]
Patch v1 View in context:
https://bugs.webkit.org/attachment.cgi?id=255717&action=review
Before we make this change, I’d like to understand more about where the string is coming from. In particular, did this already come out of a WebCore::URL, and if so, can we avoid the round trip through a string?
>>> Source/WebCore/platform/network/cf/ResourceErrorCF.cpp:157 >>> + if (RetainPtr<CFURLRef> url = URL(URL(), m_failingURL).createCFURL()) >> >> Can this be tested? >> >> As a general principle, I think that we shouldn't expose invalid URLs in API. The fact that the URL is invalid gets lost in conversion, and it's too easy for the client to make incorrect decisions based on the URL string. I can't find it now, but we even had security bugs caused by handling invalid URLs. > > It's not known how to reproduce the crash. Do you have ideas about how to reproduce it based on the crashing stack? Maybe setting the source of an iframe with an invalid URL?
I think you have an interesting point, Alexey, about invalid URLs. But please keep in mind that we are exposing that same URL above in failingURLStringKey; I am not certain that an NSURL is an additional risk.
> Source/WebCore/platform/network/mac/ResourceErrorMac.mm:186 > + if (RetainPtr<NSURL> cocoaURL = (NSURL *)URL(URL(), resourceError.failingURL()))
No reason to use RetainPtr here instead of just NSURL *. The NSURL will be autoreleased.
David Kilzer (:ddkilzer)
Comment 5
2015-12-22 20:23:27 PST
(In reply to
comment #4
)
> Comment on
attachment 255717
[details]
> Patch v1 > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=255717&action=review
> > Before we make this change, I’d like to understand more about where the > string is coming from. In particular, did this already come out of a > WebCore::URL, and if so, can we avoid the round trip through a string?
The CFErrorRef and NSError objects come from CFNetwork callbacks, so I don't think there are any round trip savings to be had here.
> >>> Source/WebCore/platform/network/cf/ResourceErrorCF.cpp:157 > >>> + if (RetainPtr<CFURLRef> url = URL(URL(), m_failingURL).createCFURL()) > >> > >> Can this be tested? > >> > >> As a general principle, I think that we shouldn't expose invalid URLs in API. The fact that the URL is invalid gets lost in conversion, and it's too easy for the client to make incorrect decisions based on the URL string. I can't find it now, but we even had security bugs caused by handling invalid URLs. > > > > It's not known how to reproduce the crash. Do you have ideas about how to reproduce it based on the crashing stack? Maybe setting the source of an iframe with an invalid URL? > > I think you have an interesting point, Alexey, about invalid URLs. But > please keep in mind that we are exposing that same URL above in > failingURLStringKey; I am not certain that an NSURL is an additional risk. > > > Source/WebCore/platform/network/mac/ResourceErrorMac.mm:186 > > + if (RetainPtr<NSURL> cocoaURL = (NSURL *)URL(URL(), resourceError.failingURL())) > > No reason to use RetainPtr here instead of just NSURL *. The NSURL will be > autoreleased.
I thought we preferred explicit retain/release instead of putting objects into autoreleasepools (generally speaking), but removing RetainPtr<> will make the conversion to ARC easier when that happens, and it's only a single object being put in the pool, so I'll change it.
David Kilzer (:ddkilzer)
Comment 6
2015-12-22 20:25:40 PST
Created
attachment 267825
[details]
Patch v2
David Kilzer (:ddkilzer)
Comment 7
2015-12-22 20:56:20 PST
(In reply to
comment #5
)
> (In reply to
comment #4
) > > Comment on
attachment 255717
[details]
> > Patch v1 > > > > View in context: > >
https://bugs.webkit.org/attachment.cgi?id=255717&action=review
> > > > Before we make this change, I’d like to understand more about where the > > string is coming from. In particular, did this already come out of a > > WebCore::URL, and if so, can we avoid the round trip through a string? > > The CFErrorRef and NSError objects come from CFNetwork callbacks, so I don't > think there are any round trip savings to be had here.
Oops, I was looking in the wrong direction! Looking at the ResourceError() constructors that use the multi-argument constructor, I think nearly all of them are converting a URL() to a String(), so we could save a round trip here. I will try changing the failingURL argument of ResourceError() from String() to URL().
David Kilzer (:ddkilzer)
Comment 8
2015-12-23 18:58:56 PST
Created
attachment 267885
[details]
Patch v3 (checking EFL/GTK builds)
WebKit Commit Bot
Comment 9
2015-12-23 18:59:47 PST
Attachment 267885
[details]
did not pass style-queue: ERROR: Source/WebCore/platform/gtk/ErrorsGtk.cpp:33: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/WebCore/platform/gtk/ErrorsGtk.cpp:39: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/WebCore/platform/gtk/ErrorsGtk.cpp:50: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/WebCore/platform/gtk/ErrorsGtk.cpp:56: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/WebCore/platform/gtk/ErrorsGtk.cpp:62: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/WebCore/platform/gtk/ErrorsGtk.cpp:68: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/WebCore/platform/gtk/ErrorsGtk.cpp:74: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/WebCore/platform/gtk/ErrorsGtk.cpp:86: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] ERROR: Source/WebCore/platform/gtk/ErrorsGtk.cpp:92: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] Total errors found: 9 in 20 files If any of these errors are false positives, please file a bug against check-webkit-style.
David Kilzer (:ddkilzer)
Comment 10
2015-12-23 19:27:05 PST
Created
attachment 267886
[details]
Patch v4
David Kilzer (:ddkilzer)
Comment 11
2015-12-23 22:24:10 PST
Created
attachment 267891
[details]
Patch v5
David Kilzer (:ddkilzer)
Comment 12
2015-12-23 22:49:35 PST
Created
attachment 267892
[details]
Patch v6
David Kilzer (:ddkilzer)
Comment 13
2015-12-24 07:56:52 PST
Created
attachment 267896
[details]
Patch v7
David Kilzer (:ddkilzer)
Comment 14
2015-12-24 08:06:35 PST
Created
attachment 267897
[details]
Patch v8
David Kilzer (:ddkilzer)
Comment 15
2015-12-24 08:22:35 PST
Created
attachment 267898
[details]
Patch v9
David Kilzer (:ddkilzer)
Comment 16
2015-12-24 08:34:10 PST
Created
attachment 267899
[details]
Patch v10
WebKit Commit Bot
Comment 17
2015-12-25 04:22:41 PST
Comment on
attachment 267899
[details]
Patch v10 Clearing flags on attachment: 267899 Committed
r194419
: <
http://trac.webkit.org/changeset/194419
>
WebKit Commit Bot
Comment 18
2015-12-25 04:22:49 PST
All reviewed patches have been landed. Closing bug.
Csaba Osztrogonác
Comment 19
2015-12-26 11:39:15 PST
(In reply to
comment #18
)
> All reviewed patches have been landed. Closing bug.
It broke the WinCairo (curl) build.
David Kilzer (:ddkilzer)
Comment 20
2015-12-31 15:28:43 PST
(In reply to
comment #19
)
> (In reply to
comment #18
) > > All reviewed patches have been landed. Closing bug. > > It broke the WinCairo (curl) build.
That build needs to be on the dashboard.
peavo
Comment 21
2016-01-04 08:21:02 PST
(In reply to
comment #20
)
> (In reply to
comment #19
) > > (In reply to
comment #18
) > > > All reviewed patches have been landed. Closing bug. > > > > It broke the WinCairo (curl) build. > > That build needs to be on the dashboard.
Yes, that would be very nice :)
Csaba Osztrogonác
Comment 22
2016-01-06 02:01:03 PST
(In reply to
comment #19
)
> (In reply to
comment #18
) > > All reviewed patches have been landed. Closing bug. > > It broke the WinCairo (curl) build.
Fixed in
bug152563
. Thanks.
Darin Adler
Comment 23
2016-01-12 08:30:57 PST
(In reply to
comment #5
)
> (In reply to
comment #4
) > > Comment on
attachment 255717
[details]
> > Patch v1 > > > > View in context: > >
https://bugs.webkit.org/attachment.cgi?id=255717&action=review
> > > > > Source/WebCore/platform/network/mac/ResourceErrorMac.mm:186 > > > + if (RetainPtr<NSURL> cocoaURL = (NSURL *)URL(URL(), resourceError.failingURL())) > > > > No reason to use RetainPtr here instead of just NSURL *. The NSURL will be > > autoreleased. > > I thought we preferred explicit retain/release instead of putting objects > into autoreleasepools (generally speaking), but removing RetainPtr<> will > make the conversion to ARC easier when that happens, and it's only a single > object being put in the pool, so I'll change it.
While this code no longer exists, I wanted to clear up a misunderstanding here. The local decision here had nothing to do with conversion to ARC. The function that converts a URL to an NSURL puts the URL into the autorelease pool. Using a RetainPtr doesn't prevent it from doing that, instead it retains and releases an additional time, unnecessarily. There's no choice between autorelease and retain/release in this code, just a choice between doing an extra retain/release or not doing it. If we wanted to use retain/release instead of an autorelease pool we would have to change the function that converts a URL into an NSURL * so that it doesn't autorelease.
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