Bug 156780

Summary: bmalloc: fix up overflow checks
Product: WebKit Reporter: Geoffrey Garen <ggaren>
Component: bmallocAssignee: Geoffrey Garen <ggaren>
Status: RESOLVED FIXED    
Severity: Normal CC: ggaren, mark.lam
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch mark.lam: review+

Description Geoffrey Garen 2016-04-19 20:09:49 PDT
bmalloc: fix up overflow checks
Comment 1 Geoffrey Garen 2016-04-19 20:12:50 PDT
Created attachment 276795 [details]
Patch
Comment 2 Mark Lam 2016-04-19 20:56:11 PDT
Comment on attachment 276795 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=276795&action=review

r=me

> Source/bmalloc/ChangeLog:11
> +        we were missing smoe cases.

typo: /smoe/some/.
Comment 3 Mark Lam 2016-04-19 20:57:04 PDT
Comment on attachment 276795 [details]
Patch

Is it possible to add some tests that exercise the overflow cases?
Comment 4 Geoffrey Garen 2016-04-19 21:12:50 PDT
> Is it possible to add some tests that exercise the overflow cases?

Good question. This requires some changes to the MallocBench infrastructure to allow for failure. I'll tackle this in a follow-up patch.
Comment 5 Geoffrey Garen 2016-04-19 21:13:43 PDT
Committed r199759: <http://trac.webkit.org/changeset/199759>
Comment 6 Oliver Hunt 2016-04-20 10:34:56 PDT
Comment on attachment 276795 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=276795&action=review

> Source/bmalloc/bmalloc/Heap.cpp:347
> +    size_t roundedSize = size ? roundUpToMultipleOf(largeAlignment, size) : largeAlignment;

I wonder if we should make an override for roundUp... to take Checked<T> - then switch to Checked<> for bmalloc internal arithmetic?
Comment 7 Geoffrey Garen 2016-04-20 11:04:37 PDT
> > Source/bmalloc/bmalloc/Heap.cpp:347
> > +    size_t roundedSize = size ? roundUpToMultipleOf(largeAlignment, size) : largeAlignment;
> 
> I wonder if we should make an override for roundUp... to take Checked<T> -
> then switch to Checked<> for bmalloc internal arithmetic?

I'd like to come up with a good idiom, maybe using builtin checked arithmetic. Not sure what the best option is.