New issue
Advanced search Search tips

Issue 691120 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Mar 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: iOS , Mac
Pri: 3
Type: Bug



Sign in to add a comment

consider building with -Wblock-capture-autoreleasing

Project Member Reported by thakis@chromium.org, Feb 10 2017

Issue description

-Wblock-capture-autoreleasing looks like a useful warning that got enabled by default in upstream clang recently. The warning fires in several places (example: https://uberchromegw.corp.google.com/i/internal.bling.fyi/builders/clang-tot-device/builds/1036/steps/compile/logs/stdio) so we have to disable the warning for now, but we should check if it's useful and consider turning it on.

Maybe one of you wants to take a look with an iOS build?
 
Cc: msarda@chromium.org
Labels: restri
I'll take a look at the rest.  Have we rolled to this clang yet or do I need to build clang tot?

msarda@ can you take a look at auth error in the link above?

Comment 2 by thakis@chromium.org, Feb 10 2017

Our current clang has this, just off by default.
msarda@ it seems like the fix is to change the method param from `NSError **` --> `NSError *__autoreleasing*`

thakis@ does that sound correct?  Some light googling gave me conflicting advice, specifically: http://clang.llvm.org/docs/AutomaticReferenceCounting.html#indirect-parameters suggests NSError ** should "be implicitly qualified with __autoreleasing."

It appears this is the only error when adding -Wblock-capture-autoreleasing
Project Member

Comment 4 by bugdroid1@chromium.org, Feb 11 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/48130024a853818d09b132c10dfca934a14e7da6

commit 48130024a853818d09b132c10dfca934a14e7da6
Author: thakis <thakis@chromium.org>
Date: Sat Feb 11 02:33:14 2017

clang: Disable -Wblock-capture-autoreleasing

This warning has existed for a while but used to be off-by-default.
Upstream made it on-by-default recently, which breaks the compile step
of the iOS ToT bot.

BUG= 691120 
TBR=hans

Review-Url: https://codereview.chromium.org/2682943010
Cr-Commit-Position: refs/heads/master@{#449837}

[modify] https://crrev.com/48130024a853818d09b132c10dfca934a14e7da6/build/config/compiler/BUILD.gn

Comment 5 by thakis@chromium.org, Feb 11 2017

justincohen: good point, let me look into that

Comment 6 by thakis@chromium.org, Feb 11 2017

Error looks like:

somefile.m: error: block captures an autoreleasing out-parameter, which may result in use-after-free bugs [-Werror,-Wblock-capture-autoreleasing]
          if (error) {
              ^
somefile.m: note: declare the parameter __autoreleasing explicitly to suppress this warning
- (NSDictionary *)fooWithError:(NSError **)error {
                                                  ^
                                                  __autoreleasing
somefile.m: note: declare the parameter __strong or capture a __block __strong variable to keep values alive across autorelease pools

Owner: justincohen@chromium.org
Status: Assigned (was: Unconfirmed)
Assigning to Justin as he said he would look into it.
Labels: -restri
thakis@ I'm not sure if the response here: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20170206/185190.html implies we need to make a change (NSError ** -> NSError * __autoreleasing*) or that it's a clang bug.
I'm not sure either :-) I'll follow up there if I don't hear back by tomorrow.
I got a reply: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20170213/185409.html

It sounds like clang does generate the code as if __autoreleasing is implicitly there at this point, but apparently this is surprising to people, so now clang warns when that happens. To suppress the warning, one has to explicitly add that __autoreleasing.

Does that make sense? Upstream is open to changing the wording of the warning if anyone has a better suggestion. But it sounds like we do want to add __autoreleasing to that file.
Status: Started (was: Assigned)
I landed the internal fix -- thakis@ can you try block-capture-autoreleasing again?
Project Member

Comment 14 by bugdroid1@chromium.org, Mar 6 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/0f16147c62ef8635f594ed77c415cc9de2ece5a6

commit 0f16147c62ef8635f594ed77c415cc9de2ece5a6
Author: thakis <thakis@chromium.org>
Date: Mon Mar 06 18:29:28 2017

clang: Stop disabling -Wblock-capture-autoreleasing

Things should build with it enabled now, and it's a useful warning.

BUG= 691120 

Review-Url: https://codereview.chromium.org/2730273002
Cr-Commit-Position: refs/heads/master@{#454895}

[modify] https://crrev.com/0f16147c62ef8635f594ed77c415cc9de2ece5a6/build/config/compiler/BUILD.gn

Status: Fixed (was: Started)

Sign in to add a comment