Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised there isn't a compiler warning enabled for this. Is it possible to enable the compiler warning as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @bolsinga do you mean the
Violation of 'self = [super init]' Rule (CLANG_ANALYZER_OBJC_SELF_INIT)
setting? It seems already enable in theBuild Settings
:pThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that warning catch this issue? I don't fully understand.
I like this change; my hope is just get the builds to fail if something like this bug should happen again. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After a further investigation at
Clang Static Analyzer
's code(ObjCSelfInitChecker) and document(osx.cocoa.SelfInit), I found the build setting ofViolation of 'self = [super init]' Rule
is not targeted for our issue, instead, it is targeted for something like:Back to our code, I think it is OK to use
self = [self init]
in_ASAsyncTransaction
, since theinit
method isn't overridden here, it's unnecessary to writeself = [super init]
. However, it is an unsafe way. Take an example, if someone subclass_ASAsyncTransaction
, overrideinit
and callinitWithCompletionBlock:
from there, this could lead to endless recursion.By searching through the codebase, this is the only place that has this bug. I suggest we use
code review
to prevent PR introducing new bug at the moment, until the compile has a more smart checker to handle it, then we enable it :) What's your opinion?