RESOLVED FIXED140194
Make bmalloc work with ASan
https://bugs.webkit.org/show_bug.cgi?id=140194
Summary Make bmalloc work with ASan
Geoffrey Garen
Reported 2015-01-07 12:41:16 PST
Make bmalloc work with ASan
Attachments
Patch (4.32 KB, patch)
2015-01-07 12:57 PST, Geoffrey Garen
no flags
Patch (4.31 KB, patch)
2015-01-07 13:00 PST, Geoffrey Garen
mark.lam: review+
Geoffrey Garen
Comment 1 2015-01-07 12:57:51 PST
Geoffrey Garen
Comment 2 2015-01-07 12:58:42 PST
Geoffrey Garen
Comment 3 2015-01-07 13:00:27 PST
WebKit Commit Bot
Comment 4 2015-01-07 13:03:31 PST
Attachment 244181 [details] did not pass style-queue: ERROR: Source/bmalloc/bmalloc/Environment.cpp:26: Found other header before WebCore config.h. Should be: config.h, primary header, blank line, and then alphabetically sorted. [build/include_order] [4] Total errors found: 1 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Mark Rowe (bdash)
Comment 5 2015-01-07 13:14:31 PST
Is there some advantage to doing the check in this manner rather than using a compile-time check as mentioned at <http://clang.llvm.org/docs/AddressSanitizer.html#has-feature-address-sanitizer>?
Mark Lam
Comment 6 2015-01-07 13:41:41 PST
Comment on attachment 244181 [details] Patch r=me
Mark Lam
Comment 7 2015-01-07 13:57:08 PST
(In reply to comment #6) > r=me I missed Mark Rowe's comment. Based on that, I think that it is better for isASanEnabled() to rely on the __has_feature(address_sanitizer) test instead of the _dyld_get_image_name checks.
Alexey Proskuryakov
Comment 8 2015-01-07 14:11:09 PST
This patch is right if bmalloc causes problems when used in a client app that is built with ASan. I.e., 1. WebKit is built without ASan (e.g. just using the shipping one in /System/Library). 2. Client app is built with ASan. There are at least two kinds of possible problems: 1. bmalloc would cause false positives. 2. bmalloc would hinder ASan's ability to find bugs in client apps. I do not know if either problem exists in practice.
Geoffrey Garen
Comment 9 2015-01-07 14:57:05 PST
(In reply to comment #8) > This patch is right if bmalloc causes problems when used in a client app > that is built with ASan. I.e., > 1. WebKit is built without ASan (e.g. just using the shipping one in > /System/Library). > 2. Client app is built with ASan. > > There are at least two kinds of possible problems: > 1. bmalloc would cause false positives. > 2. bmalloc would hinder ASan's ability to find bugs in client apps. > > I do not know if either problem exists in practice. Right -- I originally wrote a compile-time check, but then I realized that a compile-time check is not friendly to a client library or app that wants to build with ASan and then link against WebKit/JavaScriptCore that was built without it. I also plan to make bmalloc independently linkable, for clients that just want a fast malloc, and a compile-time check will be unfriendly to those clients. I don't know of any such clients that have problems right now, but I'd like to make bmalloc friendly to such clients in the future. Does that sound reasonable?
Mark Lam
Comment 10 2015-01-07 15:00:16 PST
(In reply to comment #9) > (In reply to comment #8) > > This patch is right if bmalloc causes problems when used in a client app > > that is built with ASan. I.e., > > 1. WebKit is built without ASan (e.g. just using the shipping one in > > /System/Library). > > 2. Client app is built with ASan. > > > > There are at least two kinds of possible problems: > > 1. bmalloc would cause false positives. > > 2. bmalloc would hinder ASan's ability to find bugs in client apps. > > > > I do not know if either problem exists in practice. > > Right -- I originally wrote a compile-time check, but then I realized that a > compile-time check is not friendly to a client library or app that wants to > build with ASan and then link against WebKit/JavaScriptCore that was built > without it. > > I also plan to make bmalloc independently linkable, for clients that just > want a fast malloc, and a compile-time check will be unfriendly to those > clients. > > I don't know of any such clients that have problems right now, but I'd like > to make bmalloc friendly to such clients in the future. > > Does that sound reasonable?
Mark Lam
Comment 11 2015-01-07 15:00:55 PST
(In reply to comment #9) > Does that sound reasonable? Oops ... accidentally committed last comment. Meant to say ... Sounds good to me.
Alexey Proskuryakov
Comment 12 2015-01-07 15:24:51 PST
I don't know if the theoretical problems are real, so I can't agree that the substantially more complicated runtime solution is warranted. Are there at least speculative reasons to believe that the problems are real?
Geoffrey Garen
Comment 13 2015-01-07 15:53:15 PST
> Are there at least speculative reasons to believe that the problems are real? Yes: (1) I make bmalloc a stand-alone .dylib. (2) Client [redacted] adopts bmalloc. (3) Client [redacted] adopts ASan. --> ASan doesn't work because none of [redacted]'s allocations register with ASan's runtime system. --> Client [redacted] sends me a mean email and unadopts bmalloc.
Alexey Proskuryakov
Comment 14 2015-01-07 16:40:52 PST
Yes, a bmalloc dylib case seems convincing. We just need to double-check that the dynamic check actually works in this case (unsure what guarantees that ASan dylib will be in dyld image list early enough).
David Kilzer (:ddkilzer)
Comment 15 2015-01-07 20:02:01 PST
Another option is to teach ASan about bmalloc so everything just works, although that would also rely on bmalloc exposing a stable API.
Geoffrey Garen
Comment 16 2015-01-08 16:38:49 PST
(In reply to comment #14) > Yes, a bmalloc dylib case seems convincing. We just need to double-check > that the dynamic check actually works in this case (unsure what guarantees > that ASan dylib will be in dyld image list early enough). I verified with a test program that the full list of linked libraries is available to _dyld_get_image_name() at static initialization time.
Geoffrey Garen
Comment 17 2015-01-08 16:41:55 PST
Geoffrey Garen
Comment 18 2015-01-09 16:30:54 PST
Note You need to log in before you can comment on or make changes to this bug.