Bug 179981

Summary: Fix dictionary leak in lookup, convert FindOptions to OptionSet, tweak code style nearby
Product: WebKit Reporter: Darin Adler <darin>
Component: WebCore Misc.Assignee: Darin Adler <darin>
Status: RESOLVED FIXED    
Severity: Normal CC: ews-watchlist, jlewis3, sam, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Archive of layout-test-results from ews126 for ios-simulator-wk2
none
Patch sam: review+

Darin Adler
Reported 2017-11-23 12:19:17 PST
Fix dictionary leak in lookup, convert FindOptions to OptionSet, tweak code style nearby
Attachments
Patch (123.45 KB, patch)
2017-11-23 13:06 PST, Darin Adler
no flags
Patch (125.79 KB, patch)
2017-11-23 19:21 PST, Darin Adler
no flags
Archive of layout-test-results from ews126 for ios-simulator-wk2 (2.12 MB, application/zip)
2017-11-23 20:53 PST, EWS Watchlist
no flags
Patch (126.20 KB, patch)
2017-11-24 11:33 PST, Darin Adler
sam: review+
Darin Adler
Comment 1 2017-11-23 13:06:13 PST Comment hidden (obsolete)
EWS Watchlist
Comment 2 2017-11-23 13:08:34 PST Comment hidden (obsolete)
Darin Adler
Comment 3 2017-11-23 19:21:51 PST Comment hidden (obsolete)
EWS Watchlist
Comment 4 2017-11-23 19:24:59 PST Comment hidden (obsolete)
EWS Watchlist
Comment 5 2017-11-23 20:53:56 PST Comment hidden (obsolete)
EWS Watchlist
Comment 6 2017-11-23 20:53:57 PST Comment hidden (obsolete)
Darin Adler
Comment 7 2017-11-24 11:33:06 PST
EWS Watchlist
Comment 8 2017-11-24 11:35:20 PST
Attachment 327555 [details] did not pass style-queue: ERROR: Source/WTF/wtf/OptionSet.h:133: Missing spaces around | [whitespace/operators] [3] ERROR: Source/WTF/wtf/OptionSet.h:138: Missing spaces around | [whitespace/operators] [3] Total errors found: 2 in 34 files If any of these errors are false positives, please file a bug against check-webkit-style.
Sam Weinig
Comment 9 2017-11-24 15:39:11 PST
Comment on attachment 327555 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=327555&action=review > Source/WTF/wtf/OptionSet.h:151 > + constexpr friend OptionSet operator|(OptionSet lhs, OptionSet rhs) > + { > + return fromRaw(lhs.m_storage | rhs.m_storage); > + } > + > + constexpr friend OptionSet operator|(OptionSet lhs, T rhs) > + { > + return lhs | OptionSet { rhs }; > + } > + > constexpr friend OptionSet operator-(OptionSet lhs, OptionSet rhs) > { > - return OptionSet::fromRaw(lhs.m_storage & ~rhs.m_storage); > + return fromRaw(lhs.m_storage & ~rhs.m_storage); > + } > + > + constexpr friend OptionSet operator-(OptionSet lhs, T rhs) > + { > + return lhs - OptionSet { rhs }; > } It would be good to add test cases for these to the existing OptionSet tests in TestWebKitAPI. > Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.h:111 > + std::tuple<String, RetainPtr<PDFSelection>, RetainPtr<NSDictionary>> lookupTextAtLocation(const WebCore::FloatPoint&, WebHitTestResultData&) const; I am surprised you don't have to #include <tuple>
Darin Adler
Comment 10 2017-11-24 17:08:06 PST
Comment on attachment 327555 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=327555&action=review >> Source/WTF/wtf/OptionSet.h:151 >> } > > It would be good to add test cases for these to the existing OptionSet tests in TestWebKitAPI. I will do that. In a separate patch. >> Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.h:111 >> + std::tuple<String, RetainPtr<PDFSelection>, RetainPtr<NSDictionary>> lookupTextAtLocation(const WebCore::FloatPoint&, WebHitTestResultData&) const; > > I am surprised you don't have to #include <tuple> Someone includes it I guess.
Darin Adler
Comment 11 2017-11-24 17:10:04 PST
Radar WebKit Bug Importer
Comment 12 2017-11-24 17:11:27 PST
Matt Lewis
Comment 13 2017-11-27 10:59:28 PST
This change has caused an API timeout on Sierra for the test: WKWebViewCandidateTests.ClickingInTextFieldDoesNotThrashCandidateVisibility https://build.webkit.org/builders/Apple%20Sierra%20Debug%20WK2%20(Tests)/builds/4175/steps/run-api-tests/logs/stdio https://build.webkit.org/builders/Apple%20Sierra%20Debug%20WK2%20(Tests)/builds/4175
Tim Horton
Comment 14 2017-11-27 13:15:40 PST
Comment on attachment 327555 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=327555&action=review > Source/WebCore/editing/mac/DictionaryLookup.mm:67 > + NSDictionary *retainedOptions = nil; > + auto result = [classLULookupDefinitionModule tokenRangeForString:string range:range options:&retainedOptions]; > + *options = adoptNS(retainedOptions); What led you to this leak? What indication is there that options is not autoreleased?
Darin Adler
Comment 15 2017-11-30 09:43:13 PST
(In reply to Tim Horton from comment #14) > What led you to this leak? Reading the source code. > What indication is there that options is not autoreleased? I read the source code of the LULookupDefinitionModule. Maybe I misread it?
Darin Adler
Comment 16 2017-11-30 09:45:22 PST
(In reply to Darin Adler from comment #15) > > What indication is there that options is not autoreleased? > > I read the source code of the LULookupDefinitionModule. Maybe I misread it? I did misread it! Oops, will fix right away.
Darin Adler
Comment 17 2017-11-30 09:46:16 PST
Reading the tokenRangeForString source code I saw a copy, but missed an autorelease later in the function.
Darin Adler
Comment 18 2017-11-30 09:48:54 PST
Comment on attachment 327555 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=327555&action=review >> Source/WebCore/editing/mac/DictionaryLookup.mm:67 >> + *options = adoptNS(retainedOptions); > > What led you to this leak? What indication is there that options is not autoreleased? My bad, I misread the source code to this function. I will fix this right now.
Darin Adler
Comment 19 2017-11-30 09:58:23 PST
Patch too big to just land without review, opening new bug 180202 with my patch.
Tim Horton
Comment 20 2017-11-30 09:58:56 PST
(In reply to Darin Adler from comment #19) > Patch too big to just land without review, opening new bug 180202 with my > patch. I already fixed this in https://trac.webkit.org/changeset/225196/webkit
Tim Horton
Comment 21 2017-11-30 09:59:17 PST
(In reply to Tim Horton from comment #20) > (In reply to Darin Adler from comment #19) > > Patch too big to just land without review, opening new bug 180202 with my > > patch. > > I already fixed this in https://trac.webkit.org/changeset/225196/webkit Just somehow managed to not mention it here :(
Darin Adler
Comment 22 2017-11-30 10:03:45 PST
Oops, OK.
Note You need to log in before you can comment on or make changes to this bug.