Open Quuxplusone opened 6 years ago
Ooops. I've clicked "Submit Bug" instead of "Save attachment"...
At any rate - this is what clang tells me:
export DEVELOPER_DIR=/Users/lukasza/src/chromium/src/build/mac_files/Xcode.app;
/Users/lukasza/goma/gomacc ../../third_party/llvm-
build/Release+Asserts/bin/clang++ -MMD -MF
obj/base/base_unittests/thread_annotations_unittest2.o.d -DSYSTEM_NATIVE_UTF8 -
DV8_DEPRECATION_WARNINGS -DDCHECK_ALWAYS_ON=1 -DNO_TCMALLOC -
DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -
DCHROMIUM_BUILD -DFIELDTRIAL_TESTING_ENABLED -
D_LIBCPP_HAS_NO_ALIGNED_ALLOCATION -DCR_XCODE_VERSION=0832 -
DCR_CLANG_REVISION=\"340925-1\" -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
-D_FORTIFY_SOURCE=2 -DCOMPONENT_BUILD -
D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0 -DNDEBUG -DNVALGRIND -
DDYNAMIC_ANNOTATIONS_ENABLED=0 -DGTEST_API_= -DGTEST_HAS_POSIX_RE=0 -
DGTEST_LANG_CXX11=1 -DGTEST_HAS_TR1_TUPLE=0 -DU_USING_ICU_NAMESPACE=0 -
DU_ENABLE_DYLOAD=0 -DUSE_CHROMIUM_ICU=1 -DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE
-DUCHAR_TYPE=uint16_t -DUNIT_TEST -I../.. -Igen -
I../../third_party/googletest/custom -
I../../third_party/googletest/src/googletest/include -
I../../third_party/ced/src -I../../third_party/icu/source/common -
I../../third_party/icu/source/i18n -I../../third_party/googletest/custom -
I../../third_party/googletest/src/googlemock/include -fno-strict-aliasing -
fstack-protector -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -
D__TIMESTAMP__= -fcolor-diagnostics -fmerge-all-constants -Xclang -mllvm -
Xclang -instcombine-lower-dbg-declare=0 -no-canonical-prefixes -arch x86_64 -
Wall -Werror -Wextra -Wimplicit-fallthrough -Wthread-safety -Wunguarded-
availability -Wno-missing-field-initializers -Wno-unused-parameter -Wno-c++11-
narrowing -Wno-covered-switch-default -Wno-unneeded-internal-declaration -Wno-
undefined-var-template -Wno-nonportable-include-path -Wno-user-defined-warnings
-Wno-unused-lambda-capture -Wno-null-pointer-arithmetic -Wno-enum-compare-
switch -Wno-ignored-pragma-optimize -O2 -fno-omit-frame-pointer -gdwarf-2 -
isysroot
../../build/mac_files/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
-mmacosx-version-min=10.9.0 -fvisibility=hidden -Xclang -load -Xclang
../../third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.dylib -
Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-
constructs -Xclang enforce-in-thirdparty-webkit -Xclang -plugin-arg-find-bad-
constructs -Xclang check-enum-max-value -Wheader-hygiene -Wstring-conversion -
Wtautological-overlap-compare -Wno-shorten-64-to-32 -Wno-inconsistent-missing-
override -std=c++14 -stdlib=libc++ -fobjc-call-cxx-cdtors -Wobjc-missing-
property-synthesis -fno-exceptions -fno-rtti -fvisibility-inlines-hidden -c
../../base/thread_annotations_unittest2.mm -o
obj/base/base_unittests/thread_annotations_unittest2.o
forming non-member reference to ivar?
UNREACHABLE executed at
/b/rr/tmpVpq1KP/w/src/third_party/llvm/tools/clang/lib/Sema/SemaExpr.cpp:2850!
Stack dump:
0. Program arguments: ../../third_party/llvm-build/Release+Asserts/bin/clang++ -
cc1 -triple x86_64-apple-macosx10.9.0 -Wdeprecated-objc-isa-usage -
Werror=deprecated-objc-isa-usage -emit-obj -disable-free -main-file-name
thread_annotations_unittest2.mm -mrelocation-model pic -pic-level 2 -mthread-
model posix -fmerge-all-constants -mdisable-fp-elim -relaxed-aliasing -masm-
verbose -munwind-tables -faligned-alloc-unavailable -target-cpu core2 -dwarf-
column-info -debug-info-kind=standalone -dwarf-version=2 -debugger-tuning=lldb -
target-linker-version 302.3 -coverage-notes-file
/Users/lukasza/src/chromium/src/out/rel/obj/base/base_unittests/thread_annotations_unittest2.gcno
-resource-dir ../../third_party/llvm-build/Release+Asserts/lib/clang/8.0.0 -
dependency-file obj/base/base_unittests/thread_annotations_unittest2.o.d -MT
obj/base/base_unittests/thread_annotations_unittest2.o -isysroot
../../build/mac_files/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
-D SYSTEM_NATIVE_UTF8 -D V8_DEPRECATION_WARNINGS -D DCHECK_ALWAYS_ON=1 -D
NO_TCMALLOC -D FULL_SAFE_BROWSING -D SAFE_BROWSING_CSD -D
SAFE_BROWSING_DB_LOCAL -D CHROMIUM_BUILD -D FIELDTRIAL_TESTING_ENABLED -D
_LIBCPP_HAS_NO_ALIGNED_ALLOCATION -D CR_XCODE_VERSION=0832 -D
CR_CLANG_REVISION="340925-1" -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -
D _FORTIFY_SOURCE=2 -D COMPONENT_BUILD -D
__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0 -D NDEBUG -D NVALGRIND -D
DYNAMIC_ANNOTATIONS_ENABLED=0 -D GTEST_API_= -D GTEST_HAS_POSIX_RE=0 -D
GTEST_LANG_CXX11=1 -D GTEST_HAS_TR1_TUPLE=0 -D U_USING_ICU_NAMESPACE=0 -D
U_ENABLE_DYLOAD=0 -D USE_CHROMIUM_ICU=1 -D
ICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -D UCHAR_TYPE=uint16_t -D UNIT_TEST -I
../.. -I gen -I ../../third_party/googletest/custom -I
../../third_party/googletest/src/googletest/include -I
../../third_party/ced/src -I ../../third_party/icu/source/common -I
../../third_party/icu/source/i18n -I ../../third_party/googletest/custom -I
../../third_party/googletest/src/googlemock/include -D __DATE__= -D __TIME__= -
D __TIMESTAMP__= -stdlib=libc++ -O2 -Wno-builtin-macro-redefined -Wall -Werror -
Wextra -Wimplicit-fallthrough -Wthread-safety -Wunguarded-availability -Wno-
missing-field-initializers -Wno-unused-parameter -Wno-c++11-narrowing -Wno-
covered-switch-default -Wno-unneeded-internal-declaration -Wno-undefined-var-
template -Wno-nonportable-include-path -Wno-user-defined-warnings -Wno-unused-
lambda-capture -Wno-null-pointer-arithmetic -Wno-enum-compare-switch -Wno-
ignored-pragma-optimize -Wheader-hygiene -Wstring-conversion -Wtautological-
overlap-compare -Wno-shorten-64-to-32 -Wno-inconsistent-missing-override -Wobjc-
missing-property-synthesis -std=c++14 -fdeprecated-macro -fdebug-compilation-
dir /Users/lukasza/src/chromium/src/out/rel -ferror-limit 19 -fmessage-length 0
-fvisibility hidden -fvisibility-inlines-hidden -stack-protector 1 -fblocks -
fencode-extended-block-signature -fno-rtti -fregister-global-dtors-with-atexit -
fobjc-runtime=macosx-10.9.0 -fobjc-exceptions -fexceptions -fmax-type-align=16 -
fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp -
mllvm -instcombine-lower-dbg-declare=0 -load ../../third_party/llvm-
build/Release+Asserts/lib/libFindBadConstructs.dylib -add-plugin find-bad-
constructs -plugin-arg-find-bad-constructs enforce-in-thirdparty-webkit -plugin-
arg-find-bad-constructs check-enum-max-value -o
obj/base/base_unittests/thread_annotations_unittest2.o -x objective-c++
../../base/thread_annotations_unittest2.mm
1. ../../base/thread_annotations_unittest2.mm:25:42: current parser token ')'
0 clang++ 0x000000010a3f14e5
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1 clang++ 0x000000010a3f0428 llvm::sys::RunSignalHandlers() +
248
2 clang++ 0x000000010a3f1af2
llvm::sys::PrintStackTraceOnErrorSignal(llvm::StringRef, bool) + 674
3 libsystem_platform.dylib 0x00007fff54121f5a _sigtramp + 26
4 libsystem_platform.dylib 0x00007ffee72f59a8 _sigtramp + 2468166248
5 libsystem_c.dylib 0x00007fff53ebf1ae abort + 127
6 clang++ 0x000000010a381f5c
llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 540
7 clang++ 0x000000010bb7db49
clang::Sema::BuildDeclarationNameExpr(clang::CXXScopeSpec const&,
clang::DeclarationNameInfo const&, clang::NamedDecl*, clang::NamedDecl*,
clang::TemplateArgumentListInfo const*, bool) + 2457
8 clang++ 0x000000010bb7b91d
clang::Sema::BuildDeclarationNameExpr(clang::CXXScopeSpec const&,
clang::LookupResult&, bool, bool) + 461
9 clang++ 0x000000010bb72494
clang::Sema::ActOnIdExpression(clang::Scope*, clang::CXXScopeSpec&,
clang::SourceLocation, clang::UnqualifiedId&, bool, bool,
std::__1::unique_ptr<clang::CorrectionCandidateCallback,
std::__1::default_delete<clang::CorrectionCandidateCallback> >, bool,
clang::Token*) + 4340
10 clang++ 0x000000010b65758d
clang::Parser::ParseCastExpression(bool, bool, bool&,
clang::Parser::TypeCastState, bool) + 19181
11 clang++ 0x000000010b64f494
clang::Parser::ParseAssignmentExpression(clang::Parser::TypeCastState) + 164
12 clang++ 0x000000010b617cf8
clang::Parser::ParseAttributeArgsCommon(clang::IdentifierInfo*,
clang::SourceLocation, clang::ParsedAttributes&, clang::SourceLocation*,
clang::IdentifierInfo*, clang::SourceLocation, clang::ParsedAttr::Syntax) + 3208
13 clang++ 0x000000010b616b63
clang::Parser::ParseGNUAttributeArgs(clang::IdentifierInfo*,
clang::SourceLocation, clang::ParsedAttributes&, clang::SourceLocation*,
clang::IdentifierInfo*, clang::SourceLocation, clang::ParsedAttr::Syntax,
clang::Declarator*) + 739
14 clang++ 0x000000010b616602
clang::Parser::ParseGNUAttributes(clang::ParsedAttributes&,
clang::SourceLocation*, clang::Parser::LateParsedAttrList*, clang::Declarator*)
+ 2194
15 clang++ 0x000000010b644a4b
clang::Parser::MaybeParseAndDiagnoseDeclSpecAfterCXX11VirtSpecifierSeq(clang::Declarator&,
clang::VirtSpecifiers&) + 1835
16 clang++ 0x000000010b62c219
clang::Parser::ParseStructDeclaration(clang::ParsingDeclSpec&,
llvm::function_ref<void (clang::ParsingFieldDeclarator&)>) + 1257
17 clang++ 0x000000010b67388c
clang::Parser::ParseObjCClassInstanceVariables(clang::Decl*,
clang::tok::ObjCKeywordKind, clang::SourceLocation) + 812
18 clang++ 0x000000010b670271
clang::Parser::ParseObjCAtInterfaceDeclaration(clang::SourceLocation,
clang::ParsedAttributes&) + 2417
19 clang++ 0x000000010b66f256
clang::Parser::ParseObjCAtDirectives(clang::Parser::ParsedAttributesWithRange&)
+ 310
20 clang++ 0x000000010b6bab4a
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*) + 1546
21 clang++ 0x000000010b6b9eb5
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&) + 789
22 clang++ 0x000000010b60f605 clang::ParseAST(clang::Sema&,
bool, bool) + 453
23 clang++ 0x000000010ab3138a clang::FrontendAction::Execute()
+ 138
24 clang++ 0x000000010aace361
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 929
25 clang++ 0x000000010ab8c4af
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1791
26 clang++ 0x000000010890c022 cc1_main(llvm::ArrayRef<char
const*>, char const*, void*) + 1570
27 clang++ 0x0000000108909b33 main + 11619
28 clang++ 0x0000000108906aa4 start + 52
29 clang++ 0x00000000000000bf start + 4151285327
clang++: error: unable to execute command: Abort trap: 6
clang++: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 8.0.0 (trunk 340925)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: ../../third_party/llvm-build/Release+Asserts/bin
clang++: note: diagnostic msg: PLEASE submit a bug report to
https://bugs.llvm.org/ and include the crash backtrace, preprocessed source,
and associated run script.
clang++: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang++: note: diagnostic msg:
/var/folders/vr/94yp5z115p32z44wjxy0kszh008k_r/T/thread_annotations_unittest2-733d49.mm
clang++: note: diagnostic msg:
/var/folders/vr/94yp5z115p32z44wjxy0kszh008k_r/T/thread_annotations_unittest2-733d49.sh
clang++: note: diagnostic msg: Crash backtrace is located in
clang++: note: diagnostic msg:
/Users/lukasza/Library/Logs/DiagnosticReports/clang++_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang++: note: diagnostic msg: (choose the .crash file that corresponds to your
crash)
clang++: note: diagnostic msg:
Attached thread_annotations_unittest2-733d49.mm
(916 bytes, text/plain): thread_annotations_unittest2-733d49.mm
Attached thread_annotations_unittest2-733d49.sh
(10054 bytes, text/plain): thread_annotations_unittest2-733d49.sh
Inlining contens of thread_annotations_unittest2-733d49.mm for convenience:
5 class __attribute__((lockable)) Lock {
6 public:
7 void Acquire() __attribute__((exclusive_lock_function())) {}
8 void Release() __attribute__((unlock_function())) {}
9 };
10
11 class __attribute__((scoped_lockable)) AutoLock {
12 public:
13 AutoLock(Lock& lock) __attribute__((exclusive_lock_function(lock))) : lock_(lock) {
14 lock.Acquire();
15 }
16 ~AutoLock() __attribute__((unlock_function())) { lock_.Release(); }
17
18 private:
19 Lock& lock_;
20 };
21
22 @interface MyInterface {
23 @private
24 Lock lock_;
25 int foo __attribute__((guarded_by(lock_)));
26 }
27
28 - (void)incrementFoo:(int)incrementValue;
29
30 @end
31
32 - (void)incrementFoo:(int)incrementValue {
33 AutoLock lock(lock_);
34 foo += incrementValue;
35 }
This seems like a misunderstanding between attribute handling and Objective C[++] parser. The attribute contains an expression ("lock_") that is supposed to behave as if we were in a method, but the parser (justifiably) doesn't expect that kind of expression in this context, as we aren't actually in a method. (Using C++ terminology here since I'm not familiar with Objective C.)
I'm not sure how to solve this, maybe John McCall can comment on this. The easy solution is probably to make the parser stop complaining, but maybe there are good reasons not to do so and attributes should get special treatment.
Generally I'm not sure what we can actually guarantee with regards to -Wthread-safety in Objective C[++], as this isn't really tested/documented at the time.
(In reply to Aaron Puchert from comment #4)
> This seems like a misunderstanding between attribute handling and Objective
> C[++] parser. The attribute contains an expression ("lock_") that is
> supposed to behave as if we were in a method, but the parser (justifiably)
> doesn't expect that kind of expression in this context, as we aren't
> actually in a method. (Using C++ terminology here since I'm not familiar
> with Objective C.)
>
> I'm not sure how to solve this, maybe John McCall can comment on this. The
> easy solution is probably to make the parser stop complaining, but maybe
> there are good reasons not to do so and attributes should get special
> treatment.
>
> Generally I'm not sure what we can actually guarantee with regards to
> -Wthread-safety in Objective C[++], as this isn't really tested/documented
> at the time.
C++ throws a fair number of rules at the type-checking and semantics of
references to instance members in unevaluated contexts. Objective-C has just
never had a reason to need that because it's not normally possible to write
because lookup won't find an instance variable. I would guess that the parser
here has been hacked to parse the attribute operand as if it were semantically
within the declaration, but not hacked enough to convince Sema to build a
correct ivar reference. The fix should start by investigating what's different
such that unqualified lookup can find the ivar but we're still ending up in
BuildDeclarationNameExpr trying to build a non-member reference to it; it's
possible that there's a broader bug here involved unevaluated operands.
thread_annotations_unittest2-733d49.mm
(916 bytes, text/plain)thread_annotations_unittest2-733d49.sh
(10054 bytes, text/plain)