WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
164681
Add debugging facility to limit the max single allocation size.
https://bugs.webkit.org/show_bug.cgi?id=164681
Summary
Add debugging facility to limit the max single allocation size.
Mark Lam
Reported
2016-11-12 10:23:32 PST
This is useful for simulating memory allocation failures on resource constraint devices for testing purposes.
Attachments
proposed patch.
(8.89 KB, patch)
2016-11-12 10:33 PST
,
Mark Lam
no flags
Details
Formatted Diff
Diff
proposed patch.
(9.14 KB, patch)
2016-11-13 20:51 PST
,
Mark Lam
keith_miller
: review+
Details
Formatted Diff
Diff
patch for landing.
(9.21 KB, patch)
2016-11-14 10:06 PST
,
Mark Lam
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Mark Lam
Comment 1
2016-11-12 10:33:21 PST
Created
attachment 294620
[details]
proposed patch.
JF Bastien
Comment 2
2016-11-13 10:25:04 PST
I wasn't clear to me at first that this limits *a single* allocation, not the allocated heap size. I think the wording could be improved there. Otherwise looks fine.
Mark Lam
Comment 3
2016-11-13 15:37:18 PST
(In reply to
comment #2
)
> I wasn't clear to me at first that this limits *a single* allocation, not > the allocated heap size. I think the wording could be improved there.
ChangeLog says "When in use, the max allocation size limit applies to individual allocations."
JF Bastien
Comment 4
2016-11-13 18:05:54 PST
(In reply to
comment #3
)
> (In reply to
comment #2
) > > I wasn't clear to me at first that this limits *a single* allocation, not > > the allocated heap size. I think the wording could be improved there. > > ChangeLog says "When in use, the max allocation size limit applies to > individual allocations."
I meant what the --help message says, and the name of the variable.
Mark Lam
Comment 5
2016-11-13 20:19:25 PST
(In reply to
comment #4
)
> (In reply to
comment #3
) > > (In reply to
comment #2
) > > > I wasn't clear to me at first that this limits *a single* allocation, not > > > the allocated heap size. I think the wording could be improved there. > > > > ChangeLog says "When in use, the max allocation size limit applies to > > individual allocations." > > I meant what the --help message says, and the name of the variable.
I agree that this can be better named. I'm going to change it to maxSingleAllocationSize. Updated patch coming.
Mark Lam
Comment 6
2016-11-13 20:51:11 PST
Created
attachment 294691
[details]
proposed patch.
JF Bastien
Comment 7
2016-11-13 21:10:40 PST
Comment on
attachment 294691
[details]
proposed patch. View in context:
https://bugs.webkit.org/attachment.cgi?id=294691&action=review
lgtm
> Source/WTF/wtf/FastMalloc.cpp:60 > + ASSERT_WITH_MESSAGE((size) <= maxSingleAllocationSize, "Requested size (%zu) exceeds max single allocation size set for testing (%zu)", (size), maxSingleAllocationSize)
Probably doesn't matter, but you have two invocations of size, so potentially bad if it has a side-effect.
> Source/WTF/wtf/FastMalloc.cpp:128 > + CRASH();
IIUC only the "try" variants are OK with failure? The "fast" variants didn't crash before though, right?
Mark Lam
Comment 8
2016-11-13 22:12:37 PST
Comment on
attachment 294691
[details]
proposed patch. View in context:
https://bugs.webkit.org/attachment.cgi?id=294691&action=review
>> Source/WTF/wtf/FastMalloc.cpp:60 >> + ASSERT_WITH_MESSAGE((size) <= maxSingleAllocationSize, "Requested size (%zu) exceeds max single allocation size set for testing (%zu)", (size), maxSingleAllocationSize) > > Probably doesn't matter, but you have two invocations of size, so potentially bad if it has a side-effect.
Yes doesn't matter, but if we do care about this, I can change this macro to only evaluate (size) once. Let's see what others say.
>> Source/WTF/wtf/FastMalloc.cpp:128 >> + CRASH(); > > IIUC only the "try" variants are OK with failure? The "fast" variants didn't crash before though, right?
From the ChangeLog, "fixed non-bmalloc versions of fastAlignedMalloc() to crash when allocation fails." Yes, the WebKit convention is that try allocators are supposed to return nullptr on failure to allocate, while non-try versions are to crash on failure to allocate.
Keith Miller
Comment 9
2016-11-14 09:57:40 PST
Comment on
attachment 294691
[details]
proposed patch. View in context:
https://bugs.webkit.org/attachment.cgi?id=294691&action=review
r=me.
>>> Source/WTF/wtf/FastMalloc.cpp:60 >>> + ASSERT_WITH_MESSAGE((size) <= maxSingleAllocationSize, "Requested size (%zu) exceeds max single allocation size set for testing (%zu)", (size), maxSingleAllocationSize) >> >> Probably doesn't matter, but you have two invocations of size, so potentially bad if it has a side-effect. > > Yes doesn't matter, but if we do care about this, I can change this macro to only evaluate (size) once. Let's see what others say.
I'm ok either way but I would personally change it since it can confusing when effects happen twice. Especially since the error message might be printing a different value from the one that actually crashed.
Mark Lam
Comment 10
2016-11-14 10:06:27 PST
Created
attachment 294710
[details]
patch for landing.
Mark Lam
Comment 11
2016-11-14 10:07:42 PST
Thanks for the review. Landed in
r208690
: <
http://trac.webkit.org/r208690
>.
Mark Lam
Comment 12
2016-11-14 14:22:12 PST
Build fix for windows debug build landed in
r208709
: <
http://trac.webkit.org/r208709
>.
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