WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 209464
Several refactorings done in the MemoryPressureMonitor.cpp
https://bugs.webkit.org/show_bug.cgi?id=209464
Summary
Several refactorings done in the MemoryPressureMonitor.cpp
Pablo Saavedra
Reported
2020-03-23 23:39:13 PDT
strtoull is a feature added in C++ since C11. This parses the C-string str interpreting its content as an `unsigned long long int` which is more appropriate for the size_t (unsigned integer type) variables used by the `MemoryPressureMonitor.cpp` functions in counterpoint of atoll() what returns a `long long int`.
Attachments
patch
(3.27 KB, patch)
2020-03-23 23:41 PDT
,
Pablo Saavedra
no flags
Details
Formatted Diff
Diff
patch
(13.17 KB, patch)
2020-03-26 05:53 PDT
,
Pablo Saavedra
no flags
Details
Formatted Diff
Diff
patch
(13.15 KB, patch)
2020-03-26 06:13 PDT
,
Pablo Saavedra
no flags
Details
Formatted Diff
Diff
patch
(13.15 KB, patch)
2020-03-26 06:15 PDT
,
Pablo Saavedra
no flags
Details
Formatted Diff
Diff
patch
(13.15 KB, patch)
2020-03-26 06:17 PDT
,
Pablo Saavedra
no flags
Details
Formatted Diff
Diff
patch
(13.14 KB, patch)
2020-03-31 06:33 PDT
,
Pablo Saavedra
no flags
Details
Formatted Diff
Diff
patch
(13.15 KB, patch)
2020-03-31 06:41 PDT
,
Pablo Saavedra
no flags
Details
Formatted Diff
Diff
Show Obsolete
(6)
View All
Add attachment
proposed patch, testcase, etc.
Pablo Saavedra
Comment 1
2020-03-23 23:41:41 PDT
Created
attachment 394354
[details]
patch
Adrian Perez
Comment 2
2020-03-24 01:33:34 PDT
Comment on
attachment 394354
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=394354&action=review
> Source/WebKit/UIProcess/linux/MemoryPressureMonitor.cpp:87 > + low += strtoull(token, nullptr, 10);
This is not doing any error checking to ensure that the parsing was successful. There are also a generic string-to-integer conversion function in WTF which you could use here: bool ok = true; low += WTF::toIntegralType<size_t, UChar>(token, strlen(token), &ok, 10); if (!ok) return 0; // Return early on error. …and so on for the rest of the conversions.
Pablo Saavedra
Comment 3
2020-03-26 05:53:48 PDT
Created
attachment 394598
[details]
patch
Pablo Saavedra
Comment 4
2020-03-26 06:13:09 PDT
Created
attachment 394599
[details]
patch
Pablo Saavedra
Comment 5
2020-03-26 06:15:01 PDT
Created
attachment 394600
[details]
patch
Pablo Saavedra
Comment 6
2020-03-26 06:17:31 PDT
Created
attachment 394601
[details]
patch
Pablo Saavedra
Comment 7
2020-03-26 06:25:58 PDT
(In reply to Adrian Perez from
comment #2
)
> Comment on
attachment 394354
[details]
> patch > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=394354&action=review
> > > Source/WebKit/UIProcess/linux/MemoryPressureMonitor.cpp:87 > > + low += strtoull(token, nullptr, 10); > > This is not doing any error checking to ensure that the parsing was > successful. There are also a generic string-to-integer conversion > function in WTF which you could use here: > > bool ok = true; > low += WTF::toIntegralType<size_t, UChar>(token, strlen(token), &ok, 10); > if (!ok) return 0; // Return early on error. > > …and so on for the rest of the conversions.
Thanks for your hints. I've used those in my new patch. In addition, I decided to clean up some repetitive code and fix some issues that I found running WPE in a cgroup-v2 with unified hierarchy.
Adrian Perez
Comment 8
2020-03-31 06:21:40 PDT
Comment on
attachment 394601
[details]
patch Thanks for the patch, having the checks for parsing numeric values in places and some of the duplicated code factored out makes me more confident in this being robust 👍️. Please check the comments before landing. It would be still nice to get rid of “strtok()” because often it is a source of footguns; but I do not have any good suggestion that would avoid writing a more formal parser… so let's just leave things as-is. View in context:
https://bugs.webkit.org/attachment.cgi?id=394601&action=review
> Source/WebKit/ChangeLog:34 > + getMemoryUsageWithCgroup() sighly. The name of the controller
Typo: sighly → slightly
> Source/WebKit/UIProcess/linux/MemoryPressureMonitor.cpp:232 > + CString memoryControllerPath = CString();
You can remove the “= CString()” assignment. The default constructor will initialize the value to an empty string anyway.
Pablo Saavedra
Comment 9
2020-03-31 06:33:48 PDT
Created
attachment 395030
[details]
patch
Pablo Saavedra
Comment 10
2020-03-31 06:41:52 PDT
Created
attachment 395031
[details]
patch
EWS
Comment 11
2020-03-31 07:20:46 PDT
Committed
r259287
: <
https://trac.webkit.org/changeset/259287
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 395031
[details]
.
Radar WebKit Bug Importer
Comment 12
2020-03-31 07:21:14 PDT
<
rdar://problem/61105994
>
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