RESOLVED FIXED 187422
StringView operator==(char*) should check the length of the string
https://bugs.webkit.org/show_bug.cgi?id=187422
Summary StringView operator==(char*) should check the length of the string
youenn fablet
Reported 2018-07-06 16:31:37 PDT
StringView operator==(char*) should check the length of the string
Attachments
Patch (6.22 KB, patch)
2018-07-06 16:35 PDT, youenn fablet
no flags
Patch (7.60 KB, patch)
2018-07-06 16:59 PDT, youenn fablet
no flags
Archive of layout-test-results from ews104 for mac-sierra-wk2 (3.52 MB, application/zip)
2018-07-06 18:22 PDT, EWS Watchlist
no flags
Archive of layout-test-results from ews100 for mac-sierra (2.55 MB, application/zip)
2018-07-06 18:48 PDT, EWS Watchlist
no flags
Archive of layout-test-results from ews115 for mac-sierra (3.54 MB, application/zip)
2018-07-06 19:11 PDT, EWS Watchlist
no flags
Archive of layout-test-results from ews126 for ios-simulator-wk2 (6.79 MB, application/zip)
2018-07-06 19:36 PDT, EWS Watchlist
no flags
Archive of layout-test-results from ews114 for mac-sierra (3.03 MB, application/zip)
2018-07-06 20:56 PDT, EWS Watchlist
no flags
Patch (9.86 KB, patch)
2018-07-06 21:54 PDT, youenn fablet
no flags
Patch (9.38 KB, patch)
2018-07-09 13:57 PDT, youenn fablet
no flags
youenn fablet
Comment 1 2018-07-06 16:35:32 PDT
EWS Watchlist
Comment 2 2018-07-06 16:36:40 PDT
Attachment 344482 [details] did not pass style-queue: ERROR: Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:305: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:306: Consider using EXPECT_NE instead of EXPECT_FALSE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:307: Consider using EXPECT_NE instead of EXPECT_FALSE(a == b) [readability/check] [2] Total errors found: 3 in 4 files If any of these errors are false positives, please file a bug against check-webkit-style.
youenn fablet
Comment 3 2018-07-06 16:59:51 PDT
EWS Watchlist
Comment 4 2018-07-06 17:01:11 PDT
Attachment 344490 [details] did not pass style-queue: ERROR: Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:305: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:306: Consider using EXPECT_NE instead of EXPECT_FALSE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:307: Consider using EXPECT_NE instead of EXPECT_FALSE(a == b) [readability/check] [2] Total errors found: 3 in 6 files If any of these errors are false positives, please file a bug against check-webkit-style.
EWS Watchlist
Comment 5 2018-07-06 18:22:40 PDT
Comment on attachment 344490 [details] Patch Attachment 344490 [details] did not pass mac-wk2-ews (mac-wk2): Output: https://webkit-queues.webkit.org/results/8462338 New failing tests: imported/w3c/web-platform-tests/eventsource/format-field-parsing.htm
EWS Watchlist
Comment 6 2018-07-06 18:22:41 PDT
Created attachment 344496 [details] Archive of layout-test-results from ews104 for mac-sierra-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-sierra-wk2 Platform: Mac OS X 10.12.6
EWS Watchlist
Comment 7 2018-07-06 18:48:10 PDT
Comment on attachment 344490 [details] Patch Attachment 344490 [details] did not pass mac-ews (mac): Output: https://webkit-queues.webkit.org/results/8462574 New failing tests: imported/w3c/web-platform-tests/eventsource/format-field-parsing.htm media/video-fullscreen-reload-crash.html
EWS Watchlist
Comment 8 2018-07-06 18:48:11 PDT
Created attachment 344498 [details] Archive of layout-test-results from ews100 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews100 Port: mac-sierra Platform: Mac OS X 10.12.6
EWS Watchlist
Comment 9 2018-07-06 19:11:12 PDT
Comment on attachment 344490 [details] Patch Attachment 344490 [details] did not pass mac-debug-ews (mac): Output: https://webkit-queues.webkit.org/results/8462495 New failing tests: imported/w3c/web-platform-tests/eventsource/format-field-parsing.htm
EWS Watchlist
Comment 10 2018-07-06 19:11:14 PDT
Created attachment 344501 [details] Archive of layout-test-results from ews115 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews115 Port: mac-sierra Platform: Mac OS X 10.12.6
EWS Watchlist
Comment 11 2018-07-06 19:36:12 PDT
Comment on attachment 344490 [details] Patch Attachment 344490 [details] did not pass ios-sim-ews (ios-simulator-wk2): Output: https://webkit-queues.webkit.org/results/8462694 New failing tests: imported/w3c/web-platform-tests/eventsource/format-field-parsing.htm
EWS Watchlist
Comment 12 2018-07-06 19:36:14 PDT
Created attachment 344504 [details] Archive of layout-test-results from ews126 for ios-simulator-wk2 The attached test failures were seen while running run-webkit-tests on the ios-sim-ews. Bot: ews126 Port: ios-simulator-wk2 Platform: Mac OS X 10.13.4
EWS Watchlist
Comment 13 2018-07-06 20:56:04 PDT
Comment on attachment 344490 [details] Patch Attachment 344490 [details] did not pass mac-debug-ews (mac): Output: https://webkit-queues.webkit.org/results/8463204 New failing tests: imported/w3c/web-platform-tests/eventsource/format-field-parsing.htm
EWS Watchlist
Comment 14 2018-07-06 20:56:05 PDT
Created attachment 344510 [details] Archive of layout-test-results from ews114 for mac-sierra The attached test failures were seen while running run-webkit-tests on the mac-debug-ews. Bot: ews114 Port: mac-sierra Platform: Mac OS X 10.12.6
youenn fablet
Comment 15 2018-07-06 21:54:13 PDT
EWS Watchlist
Comment 16 2018-07-06 21:55:46 PDT
Attachment 344515 [details] did not pass style-queue: ERROR: Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:305: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:306: Consider using EXPECT_NE instead of EXPECT_FALSE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:307: Consider using EXPECT_NE instead of EXPECT_FALSE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:311: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:312: Consider using EXPECT_NE instead of EXPECT_FALSE(a == b) [readability/check] [2] Total errors found: 5 in 9 files If any of these errors are false positives, please file a bug against check-webkit-style.
Chris Dumez
Comment 17 2018-07-09 09:48:32 PDT
Comment on attachment 344515 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=344515&action=review > Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:312 > + EXPECT_FALSE(a == "Hell"); Is this really the expected behavior, I would have personally expected this to be TRUE. Wouldn't strcmp() be a match here?
Saam Barati
Comment 18 2018-07-09 10:12:08 PDT
Comment on attachment 344515 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=344515&action=review > Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:310 > + a = StringView { (const LChar*)test, 5 }; static_cast >> Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:312 >> + EXPECT_FALSE(a == "Hell"); > > Is this really the expected behavior, I would have personally expected this to be TRUE. Wouldn't strcmp() be a match here? Why? Isn't the point here that our strings are allowed to have the null byte in them and they are meaningful bytes?
youenn fablet
Comment 19 2018-07-09 10:36:27 PDT
(In reply to Saam Barati from comment #18) > Comment on attachment 344515 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=344515&action=review > > > Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:310 > > + a = StringView { (const LChar*)test, 5 }; > > static_cast > > >> Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:312 > >> + EXPECT_FALSE(a == "Hell"); > > > > Is this really the expected behavior, I would have personally expected this to be TRUE. Wouldn't strcmp() be a match here? > > Why? Isn't the point here that our strings are allowed to have the null byte > in them and they are meaningful bytes? That was also my reasoning. It is true that there is some inconsistency with StringView case insensitive comparison. In that case, strlen() is used for any const char* pointer. That would mean that for "hell\0o", case insensitive check would check the first 4 bytes while for this patch, we would try to check the 6 first bytes. Also, if we were to add back a StringView operator==(char*), we would probably use strlen() and a comparison of the same pointer depending on its type might end up with different results. Maybe we should add an ASSERT there, something like ASSERT(length == strlen(b)) Or just use strlen() everywhere.
Saam Barati
Comment 20 2018-07-09 10:38:05 PDT
What does String do here?
youenn fablet
Comment 21 2018-07-09 12:22:14 PDT
auto test1 = "Hell\0"; a = StringView { (const LChar*)test1, 5 }; String test2 = a.toString(); EXPECT_FALSE(test2 == "Hell\0"); EXPECT_FALSE(test2 == "Hell"); String test3 = "Hello"; EXPECT_TRUE(test3 == "Hello\0"); EXPECT_TRUE(test3 == "Hello"); I believe String is doing as if using strlen(). It seems safer to align.
youenn fablet
Comment 22 2018-07-09 13:57:37 PDT
youenn fablet
Comment 23 2018-07-09 13:59:07 PDT
I went the strlen() easy approach. I guess we could try to optimize it here a bit but this seems more urgent to fix the correctness here.
EWS Watchlist
Comment 24 2018-07-09 14:02:06 PDT
Attachment 344611 [details] did not pass style-queue: ERROR: Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:305: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:306: Consider using EXPECT_NE instead of EXPECT_FALSE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:307: Consider using EXPECT_NE instead of EXPECT_FALSE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:311: Consider using EXPECT_NE instead of EXPECT_FALSE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:312: Consider using EXPECT_NE instead of EXPECT_FALSE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:315: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] ERROR: Tools/TestWebKitAPI/Tests/WTF/StringView.cpp:316: Consider using EXPECT_EQ instead of EXPECT_TRUE(a == b) [readability/check] [2] Total errors found: 7 in 9 files If any of these errors are false positives, please file a bug against check-webkit-style.
WebKit Commit Bot
Comment 25 2018-07-09 15:30:47 PDT
Comment on attachment 344611 [details] Patch Clearing flags on attachment: 344611 Committed r233660: <https://trac.webkit.org/changeset/233660>
WebKit Commit Bot
Comment 26 2018-07-09 15:30:49 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 27 2018-07-09 15:31:51 PDT
Zan Dobersek
Comment 28 2018-07-09 23:15:36 PDT
Comment on attachment 344611 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=344611&action=review > Source/WTF/wtf/linux/MemoryFootprintLinux.cpp:75 > - isAnonymous = pathString == "[heap]"_s || pathString.startsWith("[stack"); > + isAnonymous = pathString == "[heap]" | pathString.startsWith("[stack"); This OR operation was I guess accidentally made bitwise. Reverted in r233677. https://trac.webkit.org/changeset/233677/webkit
Note You need to log in before you can comment on or make changes to this bug.