Bug 124532 - [ASAN] Building with trunk clang corrupts sandbox profile with comment from Compiler.h
Summary: [ASAN] Building with trunk clang corrupts sandbox profile with comment from C...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac All
: P2 Normal
Assignee: David Farler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-18 12:30 PST by David Farler
Modified: 2019-05-02 16:23 PDT (History)
10 users (show)

See Also:


Attachments
Patch (1.51 KB, patch)
2014-01-07 12:28 PST, David Farler
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Farler 2013-11-18 12:30:21 PST
In https://bugs.webkit.org/show_bug.cgi?id=119165,

A preprocessor check of __clang_major__ and __clang_minor__ was added to Source/WTF/wtf/Compiler.h because of a bug with the "final" keyword.

 59 /* Disable final on versions of Apple clang earlier than 4.2 to avoid bugs like http://webkit.org/b/119165 */
 60 #if defined(__APPLE__) && (__clang_major__ < 4 || (__clang_major__ == 4 && __clang_minor__ < 2))
 61 #define WTF_COMPILER_QUIRK_FINAL_IS_BUGGY 1
 62 // #error "Please use a newer version of Xcode, this version has code generation bugs when using 'final' in C++ code"
 63 #endif

This inserts a comment into code that includes Compiler.h. However, this comment also makes its way into the WebKit2 separate process targets' sandbox profiles, for which // is syntactically invalid and causes the binaries to get killed on launch with something like this:

Nov 18 11:53:20 dmf1 com.apple.launchd[1] (com.apple.WebKit.Networking.Development.41C1A105-0D6B-49FE-8642-88B8537ECD26[93304]): Exited with code: 77
Nov 18 11:53:20 dmf1 com.apple.launchd[1] (com.apple.WebKit.WebContent.Development.F1A8659F-2388-4B1A-ADAF-26C815F35877[93305]): Exited with code: 77
Nov 18 11:57:06 dmf1.apple.com com.apple.WebKit.WebContent.Development[93637]: com.apple.WebKit.WebContent.Development: Couldn't initialize sandbox profile [/Volumes/Data/Users/davidfarler/Downloads/WebKit 2.app/Contents/Frameworks/10.9/WebKit2.framework/Resources/com.apple.WebProcess.sb], error 'line 1: unbound variable: // '

Trunk clang still identifies itself as clang 3.4:

$ xcrun clang --version
clang version 3.4 (trunk 194422)
Target: x86_64-apple-darwin13.0.0
Thread model: posix

So we need to find a proper way to identify trunk clang as well as Apple-built clang.
Comment 1 Alexey Proskuryakov 2013-11-18 13:59:28 PST
Compiler.h should obviously use c-style comments.

I'm a bit confused though. Is it even intentional that the #error is commented out? It got commented out without any explanation in <http://trac.webkit.org/changeset/157044>.
Comment 2 David Farler 2013-11-18 14:07:48 PST
(In reply to comment #1)
> Compiler.h should obviously use c-style comments.

This isn't obvious to me – what would that do in this case? ";;" are used to denote comments in sandbox profiles; would using C-style comments prevent this from getting printed to the profile or something?
Comment 3 Alexey Proskuryakov 2013-11-18 14:14:01 PST
.sb.in files are processed with a C preprocessor, which removes /**/ comments. There are lots more in Compiler.h, so this C++ one is a mistake.
Comment 4 Anders Carlsson 2013-11-18 14:16:04 PST
(In reply to comment #1)
> Compiler.h should obviously use c-style comments.
> 
> I'm a bit confused though. Is it even intentional that the #error is commented out? It got commented out without any explanation in <http://trac.webkit.org/changeset/157044>.

It was unintentional. I was using a trunk build of clang and probably ran into the same error as David’s seeing now.

Since we only build on Xcode 5 now we can probably remove the quirk altogether.
Comment 5 David Farler 2014-01-07 12:28:05 PST
Created attachment 220539 [details]
Patch
Comment 6 David Kilzer (:ddkilzer) 2014-01-07 12:29:38 PST
Comment on attachment 220539 [details]
Patch

r=me
Comment 7 WebKit Commit Bot 2014-01-07 13:03:08 PST
Comment on attachment 220539 [details]
Patch

Clearing flags on attachment: 220539

Committed r161451: <http://trac.webkit.org/changeset/161451>
Comment 8 WebKit Commit Bot 2014-01-07 13:03:11 PST
All reviewed patches have been landed.  Closing bug.