RESOLVED FIXED 142443
bmalloc: tryFastMalloc shouldn't crash
https://bugs.webkit.org/show_bug.cgi?id=142443
Summary bmalloc: tryFastMalloc shouldn't crash
Geoffrey Garen
Reported 2015-03-07 17:46:54 PST
bmalloc: tryFastMalloc shouldn't crash
Attachments
Patch (10.39 KB, patch)
2015-03-07 17:55 PST, Geoffrey Garen
no flags
Patch (10.38 KB, patch)
2015-03-07 19:13 PST, Geoffrey Garen
no flags
Archive of layout-test-results from ews101 for mac-mavericks (583.87 KB, application/zip)
2015-03-07 20:29 PST, Build Bot
no flags
Archive of layout-test-results from ews107 for mac-mavericks-wk2 (752.74 KB, application/zip)
2015-03-07 20:35 PST, Build Bot
no flags
Patch (10.66 KB, patch)
2015-03-08 15:28 PDT, Geoffrey Garen
no flags
Archive of layout-test-results from ews101 for mac-mavericks (638.19 KB, application/zip)
2015-03-08 17:01 PDT, Build Bot
no flags
Patch (1.65 KB, patch)
2015-03-08 19:30 PDT, Geoffrey Garen
no flags
Patch (4.26 KB, patch)
2015-03-09 09:03 PDT, Geoffrey Garen
no flags
Patch (10.10 KB, patch)
2015-03-09 16:43 PDT, Geoffrey Garen
no flags
Patch (10.14 KB, patch)
2015-03-09 16:49 PDT, Geoffrey Garen
no flags
Patch (12.51 KB, patch)
2015-03-10 11:00 PDT, Geoffrey Garen
no flags
Geoffrey Garen
Comment 1 2015-03-07 17:55:09 PST
Geoffrey Garen
Comment 2 2015-03-07 19:13:49 PST
Build Bot
Comment 3 2015-03-07 20:29:00 PST
Comment on attachment 248173 [details] Patch Attachment 248173 [details] did not pass mac-ews (mac): Output: http://webkit-queues.appspot.com/results/6160743829340160 New failing tests: svg/custom/absolute-root-position-masking.xhtml js/regress/exit-length-on-plain-object.html
Build Bot
Comment 4 2015-03-07 20:29:03 PST
Created attachment 248176 [details] Archive of layout-test-results from ews101 for mac-mavericks The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews101 Port: mac-mavericks Platform: Mac OS X 10.9.5
Build Bot
Comment 5 2015-03-07 20:35:34 PST
Comment on attachment 248173 [details] Patch Attachment 248173 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.appspot.com/results/6145023175294976 New failing tests: fast/history/replacestate-nocrash.html fast/multicol/newmulticol/multicol-inside-multicol.html platform/mac-wk2/plugins/muted-state.html
Build Bot
Comment 6 2015-03-07 20:35:38 PST
Created attachment 248177 [details] Archive of layout-test-results from ews107 for mac-mavericks-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews107 Port: mac-mavericks-wk2 Platform: Mac OS X 10.9.5
Brent Fulgham
Comment 7 2015-03-08 12:27:22 PDT
Comment on attachment 248173 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=248173&action=review > Source/WTF/wtf/FastMalloc.cpp:192 > + return bmalloc::api::malloc(size); Would it make sense for these to be in the header so they could be inlined?
Geoffrey Garen
Comment 8 2015-03-08 15:03:12 PDT
> > Source/WTF/wtf/FastMalloc.cpp:192 > > + return bmalloc::api::malloc(size); > > Would it make sense for these to be in the header so they could be inlined? Currently, WTF::fastMalloc is an out-of-line function, but bmalloc::api::malloc is fully inlined into it. That's pretty good. We probably don't want to inline the whole malloc function -- it's a bit too big. But we probably do want to inline the size class calculation eventually, since it's constant.
Geoffrey Garen
Comment 9 2015-03-08 15:28:11 PDT
Build Bot
Comment 10 2015-03-08 17:01:20 PDT
Comment on attachment 248210 [details] Patch Attachment 248210 [details] did not pass mac-ews (mac): Output: http://webkit-queues.appspot.com/results/5808178553946112 New failing tests: fast/multicol/newmulticol/multicol-inside-multicol.html
Build Bot
Comment 11 2015-03-08 17:01:23 PDT
Created attachment 248220 [details] Archive of layout-test-results from ews101 for mac-mavericks The attached test failures were seen while running run-webkit-tests on the mac-ews. Bot: ews101 Port: mac-mavericks Platform: Mac OS X 10.9.5
Darin Adler
Comment 12 2015-03-08 19:23:52 PDT
Comment on attachment 248210 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=248210&action=review Tests seem to be failing on EWS. Please don’t land until you find out why. > Source/WTF/ChangeLog:14 > + * wtf/FastMalloc.cpp: > + (WTF::fastMalloc): > + (WTF::fastCalloc): > + (WTF::fastRealloc): > + (WTF::fastAlignedMalloc): Don't check for NULL; bmalloc will just crash > + for us if allocation fails, and we'd rather not pay the cost of an extra > + check. Very interesting. I had no idea! (As you can tell since I wrote all that wrong code.) > Source/WebKit2/Shared/ShareableBitmap.cpp:149 > + char* data = 0; nullptr > Source/WebKit2/Shared/ShareableBitmap.cpp:155 > + fastFree(m_data); Seems unfortunate that we can’t free the old data before allocating the new data; one advantage of the old realloc code path is that it combined the new allocation with the old deallocation. We don’t want to reuse the data, but it would be nice to be able to reuse the memory. Perhaps my naiveté about malloc is showing, though.
Darin Adler
Comment 13 2015-03-08 19:25:23 PDT
I think it’s strange that bmalloc has an entry point named malloc that is “crash on fail” rather than “return null on fail”. That differs from the traditional meaning of the malloc C library function although it matches the behavior of our fastMalloc function.
Geoffrey Garen
Comment 14 2015-03-08 19:30:25 PDT
Geoffrey Garen
Comment 15 2015-03-08 22:43:34 PDT
> Tests seem to be failing on EWS. Please don’t land until you find out why. OK. > > Source/WebKit2/Shared/ShareableBitmap.cpp:155 > > + fastFree(m_data); > > Seems unfortunate that we can’t free the old data before allocating the new > data; one advantage of the old realloc code path is that it combined the new > allocation with the old deallocation. We don’t want to reuse the data, but > it would be nice to be able to reuse the memory. Perhaps my naiveté about > malloc is showing, though. Since realloc must copy the contents of the old buffer, it's not allowed to free the old buffer before allocating the new one.
Geoffrey Garen
Comment 16 2015-03-08 22:46:03 PDT
> I think it’s strange that bmalloc has an entry point named malloc that is > “crash on fail” rather than “return null on fail”. That differs from the > traditional meaning of the malloc C library function although it matches the > behavior of our fastMalloc function. Yeah. I never really thought through the crash vs return null behavior, and now that I think about it, it's probably not right to call the functions malloc and realloc -- it's more like mallocOrCrash and reallocOrCrash, or something.
Darin Adler
Comment 17 2015-03-09 00:08:18 PDT
Comment on attachment 248224 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=248224&action=review > Source/WebKit2/Shared/ShareableBitmap.cpp:149 > + char* data = 0; nullptr
Darin Adler
Comment 18 2015-03-09 00:09:30 PDT
(In reply to comment #15) > > > Source/WebKit2/Shared/ShareableBitmap.cpp:155 > > > + fastFree(m_data); > > > > Seems unfortunate that we can’t free the old data before allocating the new > > data; one advantage of the old realloc code path is that it combined the new > > allocation with the old deallocation. We don’t want to reuse the data, but > > it would be nice to be able to reuse the memory. Perhaps my naiveté about > > malloc is showing, though. > > Since realloc must copy the contents of the old buffer, it's not allowed to > free the old buffer before allocating the new one. Still seems like a missed opportunity here. Not something we were doing before, but something we could do. Again, not sure if it’s realistic to expect one free to help the other allocate to succeed.
Geoffrey Garen
Comment 19 2015-03-09 07:50:08 PDT
> Still seems like a missed opportunity here. Not something we were doing > before, but something we could do. Ah, I see. Yes, I think we could do it.
Geoffrey Garen
Comment 20 2015-03-09 09:03:55 PDT
Geoffrey Garen
Comment 21 2015-03-09 11:43:33 PDT
Geoffrey Garen
Comment 22 2015-03-09 16:43:51 PDT
Reopening to attach new patch.
Geoffrey Garen
Comment 23 2015-03-09 16:43:53 PDT
Geoffrey Garen
Comment 24 2015-03-09 16:44:09 PDT
This time for sure!
Geoffrey Garen
Comment 25 2015-03-09 16:49:46 PDT
Geoffrey Garen
Comment 26 2015-03-09 21:10:42 PDT
Alexey Proskuryakov
Comment 27 2015-03-09 23:44:59 PDT
This seems to have somehow broken ASan tests, with a nondescript error. I'm going to try rolling out. r181306 was fine, r181308 crashes on many tests.
WebKit Commit Bot
Comment 28 2015-03-09 23:47:30 PDT
Re-opened since this is blocked by bug 142525
Geoffrey Garen
Comment 29 2015-03-10 11:00:12 PDT
Geoffrey Garen
Comment 30 2015-03-10 11:01:27 PDT
Note You need to log in before you can comment on or make changes to this bug.