Bug 57502

Summary: Make malloc validation useful
Product: WebKit Reporter: Oliver Hunt <oliver>
Component: Web Template FrameworkAssignee: Oliver Hunt <oliver>
Status: REOPENED ---    
Severity: Normal CC: abarth, buildbot, darin, eric, ggaren, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Other   
OS: OS X 10.5   
Bug Depends on: 57816    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

Description Oliver Hunt 2011-03-30 13:33:57 PDT
Make malloc validation useful
Comment 1 Oliver Hunt 2011-03-30 13:37:49 PDT
Created attachment 87606 [details]
Patch
Comment 2 WebKit Review Bot 2011-03-30 13:42:55 PDT
Attachment 87606 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/ChangeLog', u'Source..." exit_code: 1

Source/JavaScriptCore/wtf/FastMalloc.h:193:  Should have a space between // and comment  [whitespace/comments] [4]
Source/JavaScriptCore/wtf/FastMalloc.cpp:169:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Source/JavaScriptCore/wtf/FastMalloc.cpp:227:  One space before end of line comments  [whitespace/comments] [5]
Source/JavaScriptCore/wtf/FastMalloc.cpp:340:  One space before end of line comments  [whitespace/comments] [5]
Source/JavaScriptCore/wtf/FastMalloc.cpp:1304:  pageheap_lock is incorrectly named. Don't use underscores in your identifier names.  [readability/naming] [4]
Source/JavaScriptCore/wtf/FastMalloc.cpp:2480:  Should have a space between // and comment  [whitespace/comments] [4]
Source/JavaScriptCore/wtf/FastMalloc.cpp:3827:  One space before end of line comments  [whitespace/comments] [5]
Source/JavaScriptCore/wtf/FastMalloc.cpp:3992:  One space before end of line comments  [whitespace/comments] [5]
Total errors found: 8 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Build Bot 2011-03-30 14:35:32 PDT
Attachment 87606 [details] did not build on win:
Build output: http://queues.webkit.org/results/8280969
Comment 4 Geoffrey Garen 2011-03-30 14:43:24 PDT
2>..\..\wtf\FastMalloc.cpp(236) : error C2220: warning treated as error - no 'object' file generated
2>..\..\wtf\FastMalloc.cpp(236) : warning C4245: '=' : conversion from '' to 'WTF::Internal::ValidationTag', signed/unsigned mismatch
Comment 5 Geoffrey Garen 2011-03-30 14:49:36 PDT
+    memset(p, 0xCC, header->m_size);

I think 0xbbadbeef would be better, since that's that standard dereference we look for to indicate assertion failure.

+        //if (Internal::fastMallocMatchValidationType(p) != allocType)
+        //    Internal::fastMallocMatchFailed(p);

Boo on commented-out code.

+    //ASSERT(IsHeld(pageheap_lock));

Boo on commented-out code.

-    ASSERT(IsHeld(pageheap_lock));
+    ASSERT(pageheap_lock.IsHeld());

Why all of these changes?

r- because of the build failure.
Comment 6 Oliver Hunt 2011-03-30 14:53:03 PDT
(In reply to comment #5)
> +    memset(p, 0xCC, header->m_size);
> 
> I think 0xbbadbeef would be better, since that's that standard dereference we look for to indicate assertion failure.

yeah you'd think memset would be able to plan an entire int given that it takes an int argument, but it converts to unsigned char first.  Hence 0xCC.

> 
> +        //if (Internal::fastMallocMatchValidationType(p) != allocType)
> +        //    Internal::fastMallocMatchFailed(p);
> 
> Boo on commented-out code.
Removed -- it would be nice to add this back, but currently new/free mismatches exist all over the place

> 
> +    //ASSERT(IsHeld(pageheap_lock));
> 
> Boo on commented-out code.
Fixed

> 
> -    ASSERT(IsHeld(pageheap_lock));
> +    ASSERT(pageheap_lock.IsHeld());
> 
> Why all of these changes?

Apparently no one has done a debug build of fast malloc for a long time.

> 
> r- because of the build failure.
Comment 7 Oliver Hunt 2011-03-30 14:53:20 PDT
Created attachment 87622 [details]
Patch
Comment 8 WebKit Review Bot 2011-03-30 14:55:20 PDT
Attachment 87622 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/ChangeLog', u'Source..." exit_code: 1

Source/JavaScriptCore/wtf/FastMalloc.cpp:169:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Source/JavaScriptCore/wtf/FastMalloc.cpp:227:  One space before end of line comments  [whitespace/comments] [5]
Source/JavaScriptCore/wtf/FastMalloc.cpp:340:  One space before end of line comments  [whitespace/comments] [5]
Source/JavaScriptCore/wtf/FastMalloc.cpp:1304:  pageheap_lock is incorrectly named. Don't use underscores in your identifier names.  [readability/naming] [4]
Source/JavaScriptCore/wtf/FastMalloc.cpp:3827:  One space before end of line comments  [whitespace/comments] [5]
Source/JavaScriptCore/wtf/FastMalloc.cpp:3992:  One space before end of line comments  [whitespace/comments] [5]
Total errors found: 6 in 5 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 9 Build Bot 2011-03-30 16:12:27 PDT
Attachment 87622 [details] did not build on win:
Build output: http://queues.webkit.org/results/8311020
Comment 10 Geoffrey Garen 2011-04-04 10:37:23 PDT
Comment on attachment 87622 [details]
Patch

Still failing to build.
Comment 11 Oliver Hunt 2011-04-04 11:57:44 PDT
Created attachment 88089 [details]
Patch
Comment 12 WebKit Review Bot 2011-04-04 12:01:16 PDT
Attachment 88089 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style']" exit_code: 1

Source/JavaScriptCore/wtf/FastMalloc.cpp:169:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Source/JavaScriptCore/wtf/FastMalloc.cpp:227:  One space before end of line comments  [whitespace/comments] [5]
Source/JavaScriptCore/wtf/FastMalloc.cpp:340:  One space before end of line comments  [whitespace/comments] [5]
Source/JavaScriptCore/wtf/FastMalloc.cpp:1304:  pageheap_lock is incorrectly named. Don't use underscores in your identifier names.  [readability/naming] [4]
Source/JavaScriptCore/wtf/FastMalloc.cpp:3827:  One space before end of line comments  [whitespace/comments] [5]
Source/JavaScriptCore/wtf/FastMalloc.cpp:3992:  One space before end of line comments  [whitespace/comments] [5]
Total errors found: 6 in 6 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 13 Oliver Hunt 2011-04-04 12:49:26 PDT
Created attachment 88103 [details]
Patch
Comment 14 WebKit Review Bot 2011-04-04 12:52:40 PDT
Attachment 88103 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style']" exit_code: 1

Source/JavaScriptCore/wtf/FastMalloc.cpp:169:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Source/JavaScriptCore/wtf/FastMalloc.cpp:227:  One space before end of line comments  [whitespace/comments] [5]
Source/JavaScriptCore/wtf/FastMalloc.cpp:340:  One space before end of line comments  [whitespace/comments] [5]
Source/JavaScriptCore/wtf/FastMalloc.cpp:1306:  pageheap_lock is incorrectly named. Don't use underscores in your identifier names.  [readability/naming] [4]
Source/JavaScriptCore/wtf/FastMalloc.cpp:3829:  One space before end of line comments  [whitespace/comments] [5]
Source/JavaScriptCore/wtf/FastMalloc.cpp:3994:  One space before end of line comments  [whitespace/comments] [5]
Total errors found: 6 in 6 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 15 Geoffrey Garen 2011-04-04 13:19:06 PDT
Comment on attachment 88103 [details]
Patch

r=me, now that the build works and debug builds do not ASSERT.
Comment 16 Oliver Hunt 2011-04-04 15:01:04 PDT
Committed r82876: <http://trac.webkit.org/changeset/82876>
Comment 17 WebKit Review Bot 2011-04-04 15:29:47 PDT
http://trac.webkit.org/changeset/82876 might have broken GTK Linux 32-bit Release
Comment 18 Kent Tamura 2011-04-04 22:42:55 PDT
(In reply to comment #16)
> Committed r82876: <http://trac.webkit.org/changeset/82876>

I reverted it because of test crashes on the SnowLeopard bot. (Release-only?)