WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
144908
[GTK] Avoid std::chrono::microseconds overflows in setSharedTimerFireInterval
https://bugs.webkit.org/show_bug.cgi?id=144908
Summary
[GTK] Avoid std::chrono::microseconds overflows in setSharedTimerFireInterval
Zan Dobersek
Reported
2015-05-12 06:14:25 PDT
[GTK] Avoid std::chrono::microseconds overflows in setSharedTimerFireInterval
Attachments
Patch
(2.67 KB, patch)
2015-05-12 06:31 PDT
,
Zan Dobersek
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Zan Dobersek
Comment 1
2015-05-12 06:31:25 PDT
Created
attachment 252960
[details]
Patch
Carlos Garcia Campos
Comment 2
2015-05-12 06:44:50 PDT
Comment on
attachment 252960
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=252960&action=review
> Source/WebCore/platform/gtk/SharedTimerGtk.cpp:53 > + // Passed-in value is in seconds, which might overflow when casting to std::chrono::microseconds. > + auto interval = std::chrono::duration<double>(intervalValue); > + auto delay = std::chrono::microseconds::max(); > + if (interval < delay) > + delay = std::chrono::duration_cast<std::chrono::microseconds>(interval);
Could we do something like this in GMainLoopSource instead? To fix any other cases where we are passing a double casted to microseconds.
Zan Dobersek
Comment 3
2015-05-12 06:59:22 PDT
Comment on
attachment 252960
[details]
Patch Needs a bit more thought.
Darin Adler
Comment 4
2015-05-17 10:26:16 PDT
Comment on
attachment 252960
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=252960&action=review
> Source/WebCore/platform/gtk/SharedTimerGtk.cpp:49 > + // Passed-in value is in seconds, which might overflow when casting to std::chrono::microseconds.
This seems like an issue that might happen cross-platform as we move from the traditional “doubles in seconds” to std::chrono across the board. I wonder what the good idiom to avoid this is.
Zan Dobersek
Comment 5
2015-12-07 02:18:44 PST
A version of this patch landed in
r192058
.
https://trac.webkit.org/changeset/192058
Zan Dobersek
Comment 6
2015-12-07 02:20:47 PST
(In reply to
comment #4
)
> Comment on
attachment 252960
[details]
> Patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=252960&action=review
> > > Source/WebCore/platform/gtk/SharedTimerGtk.cpp:49 > > + // Passed-in value is in seconds, which might overflow when casting to std::chrono::microseconds. > > This seems like an issue that might happen cross-platform as we move from > the traditional “doubles in seconds” to std::chrono across the board. I > wonder what the good idiom to avoid this is.
If possible, we could try specializing the std::chrono::duration<> template for the WTF::Checked class.
Darin Adler
Comment 7
2015-12-07 10:01:35 PST
For most uses we might need clamping casts that turn out-of-range values into min/max.
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