Title: [279027] trunk
- Revision
- 279027
- Author
- [email protected]
- Date
- 2021-06-17 18:27:53 -0700 (Thu, 17 Jun 2021)
Log Message
[Win] WTF.ParseInteger and WTF.ParseIntegerAllowingTrailingJunk are failing
https://bugs.webkit.org/show_bug.cgi?id=227090
Reviewed by Yusuke Suzuki.
Source/WTF:
ArithmeticOperations::sub unexpectedly reported an overflow for
the result of std::numeric_limits<ResultType>::min() in MSVC code path.
For example, Checked<int, RecordOverflow>(INT_MIN + 1) - 1 was reported an overflow.
In the case of calculating (lhs - rhs), and lhs < 0 and rhs > 0,
the original code reported an overflow if (rhs > max() + lhs).
Mathematically, this condition checks (lhs - rhs < -max()).
It should use min() instead of max() in this case. It should be
(lhs - rhs < min()) mathematically.
* wtf/CheckedArithmetic.h:
Tools:
* TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp:
(TestWebKitAPI::AllowMixedSignednessTest::run):
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (279026 => 279027)
--- trunk/Source/WTF/ChangeLog 2021-06-18 00:26:11 UTC (rev 279026)
+++ trunk/Source/WTF/ChangeLog 2021-06-18 01:27:53 UTC (rev 279027)
@@ -1,3 +1,22 @@
+2021-06-17 Fujii Hironori <[email protected]>
+
+ [Win] WTF.ParseInteger and WTF.ParseIntegerAllowingTrailingJunk are failing
+ https://bugs.webkit.org/show_bug.cgi?id=227090
+
+ Reviewed by Yusuke Suzuki.
+
+ ArithmeticOperations::sub unexpectedly reported an overflow for
+ the result of std::numeric_limits<ResultType>::min() in MSVC code path.
+ For example, Checked<int, RecordOverflow>(INT_MIN + 1) - 1 was reported an overflow.
+
+ In the case of calculating (lhs - rhs), and lhs < 0 and rhs > 0,
+ the original code reported an overflow if (rhs > max() + lhs).
+ Mathematically, this condition checks (lhs - rhs < -max()).
+ It should use min() instead of max() in this case. It should be
+ (lhs - rhs < min()) mathematically.
+
+ * wtf/CheckedArithmetic.h:
+
2021-06-17 Alex Christensen <[email protected]>
Add assertion in RunLoop::dispatch
Modified: trunk/Source/WTF/wtf/CheckedArithmetic.h (279026 => 279027)
--- trunk/Source/WTF/wtf/CheckedArithmetic.h 2021-06-18 00:26:11 UTC (rev 279026)
+++ trunk/Source/WTF/wtf/CheckedArithmetic.h 2021-06-18 01:27:53 UTC (rev 279027)
@@ -326,7 +326,7 @@
if (lhs > std::numeric_limits<ResultType>::max() + rhs)
return false;
} else {
- if (rhs > std::numeric_limits<ResultType>::max() + lhs)
+ if (lhs < std::numeric_limits<ResultType>::min() + rhs)
return false;
}
} // if the signs match this operation can't overflow
Modified: trunk/Tools/ChangeLog (279026 => 279027)
--- trunk/Tools/ChangeLog 2021-06-18 00:26:11 UTC (rev 279026)
+++ trunk/Tools/ChangeLog 2021-06-18 01:27:53 UTC (rev 279027)
@@ -1,3 +1,13 @@
+2021-06-17 Fujii Hironori <[email protected]>
+
+ [Win] WTF.ParseInteger and WTF.ParseIntegerAllowingTrailingJunk are failing
+ https://bugs.webkit.org/show_bug.cgi?id=227090
+
+ Reviewed by Yusuke Suzuki.
+
+ * TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp:
+ (TestWebKitAPI::AllowMixedSignednessTest::run):
+
2021-06-17 Jonathan Bedard <[email protected]>
[resultsdbpy] Adopt autoinstaller
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp (279026 => 279027)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp 2021-06-18 00:26:11 UTC (rev 279026)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/CheckedArithmeticOperations.cpp 2021-06-18 01:27:53 UTC (rev 279027)
@@ -387,6 +387,10 @@
value = std::numeric_limits<type>::max();
EXPECT_EQ(true, (value += 1U).hasOverflowed());
EXPECT_EQ(true, value.hasOverflowed());
+ value = std::numeric_limits<type>::max() - 1;
+ EXPECT_FALSE((value + 1).hasOverflowed());
+ value = std::numeric_limits<type>::min() + 1;
+ EXPECT_FALSE((value - 1).hasOverflowed());
}
};
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes