Bug 181309 - Sandbox preprocessing should handle C++ comments
Summary: Sandbox preprocessing should handle C++ comments
Status: RESOLVED DUPLICATE of bug 184166
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Brent Fulgham
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-01-04 14:54 PST by Brent Fulgham
Modified: 2018-03-31 23:03 PDT (History)
6 users (show)

See Also:


Attachments
Patch (1.60 KB, patch)
2018-01-04 15:02 PST, Brent Fulgham
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Fulgham 2018-01-04 14:54:38 PST
The text preprocessing rules in WebKit's DerivedSources.make is now only used for processing our sandbox profiles. Sometimes the headers and availability macros included on macOS and iOS SDK's have spurious C++-style comments in them, which are not stripped out during preprocessing since we were telling clang to use C89 rules for preprocessing.

Instead, we should switch to C99 so that C++-style comments will get properly ignored, and we won't confuse the Sandbox library when it tries the read the finished file.
Comment 1 Radar WebKit Bug Importer 2018-01-04 14:59:33 PST
<rdar://problem/36306874>
Comment 2 Brent Fulgham 2018-01-04 15:02:03 PST
Created attachment 330490 [details]
Patch
Comment 3 Alexey Proskuryakov 2018-01-04 16:16:54 PST
Comment on attachment 330490 [details]
Patch

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

> Source/WebKit/ChangeLog:9
> +        Switch to C99 rules for preprocessing our sandbox profiles. No other code uses the TEXT_PREPROCESSOR_FLAGS

Can you diff processed profiles? This seems likely to break all comments with "rdar://" in them. Theoretically, it can break actual rules if they have double slashes, but we don't have any like that now.
Comment 4 Brent Fulgham 2018-01-04 16:25:27 PST
Comment on attachment 330490 [details]
Patch

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

>> Source/WebKit/ChangeLog:9
>> +        Switch to C99 rules for preprocessing our sandbox profiles. No other code uses the TEXT_PREPROCESSOR_FLAGS
> 
> Can you diff processed profiles? This seems likely to break all comments with "rdar://" in them. Theoretically, it can break actual rules if they have double slashes, but we don't have any like that now.

Yes -- it definitely cuts off everything after the "//" in the comment, so maybe we don't want to do that.

We should probably create a WebKit-specific filter program that does exactly what we want.
Comment 5 Darin Adler 2018-01-07 22:56:44 PST
Comment on attachment 330490 [details]
Patch

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

>>> Source/WebKit/ChangeLog:9
>>> +        Switch to C99 rules for preprocessing our sandbox profiles. No other code uses the TEXT_PREPROCESSOR_FLAGS
>> 
>> Can you diff processed profiles? This seems likely to break all comments with "rdar://" in them. Theoretically, it can break actual rules if they have double slashes, but we don't have any like that now.
> 
> Yes -- it definitely cuts off everything after the "//" in the comment, so maybe we don't want to do that.
> 
> We should probably create a WebKit-specific filter program that does exactly what we want.

No, I don’t think this will break /* */ comments with // inside them. Those work fine in C++; why wouldn’t clang handle that properly?

Actual rules with double slashes is something different, though. Maybe that’s important?
Comment 6 Alexey Proskuryakov 2018-01-08 09:35:04 PST
The comments in .sb.in files are of this form:

    ; "com.apple.coremedia.endpointpicker.xpc" can be removed when <rdar://problem/30081582> is resolved.

And with this patch, the built .sb file has lines like this:

    ; "com.apple.coremedia.endpointpicker.xpc" can be removed when <rdar:

I don't think that it's particularly important to preserve comments in sandbox profiles, so maybe the solution is to switch from ";" to "//" for comments. The only downside will be that comments will be inconsistent between processed and non-processed sandbox profile sources (e.g. Source/WebKit/NetworkProcess/mac/com.apple.WebKit.NetworkProcess.sb.in vs. Source/WebKit/Resources/SandboxProfiles/ios/com.apple.WebKit.Networking.sb).

And yes, rules with double slashes are probably not important. If one is ever introduced, this will almost certainly break profile compilation, so bots will quickly tell us about the problem.
Comment 7 Alexey Proskuryakov 2018-03-31 23:03:08 PDT

*** This bug has been marked as a duplicate of bug 184166 ***