New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-11737] Missing throws in @objc protocol conformance with parameter segfaults #54144
Comments
This doesn't crash on master |
I reproduced this on swift-5.1-branch, but not master. With the 11/1 5.1 snapshot, I get: Assertion failed: (Index < this->size() && "Invalid index!"), function operator[], file /Users/buildnode/jenkins/workspace/oss-swift-5.1-package-osx/llvm/include/llvm/ADT/ArrayRef.h, line 418.
Stack dump:
0. Program arguments: /Library/Developer/Toolchains/swift-5.1-DEVELOPMENT-SNAPSHOT-2019-11-01-a.xctoolchain/usr/bin/swift -frontend -merge-modules -emit-module /Users/brent/Library/Developer/Xcode/DerivedData/ThrowingSegFault-ctdhitedqwltsacnwezxlpqhruzp/Build/Intermediates.noindex/ThrowingSegFault.build/Debug/ThrowingSegFault.build/Objects-normal/x86_64/Muppet~partial.swiftmodule -parse-as-library -sil-merge-partial-modules -disable-diagnostic-passes -disable-sil-perf-optzns -target x86_64-apple-macos10.14 -enable-objc-interop -sdk /Applications/Xcode-YellowstoneB.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -I /Users/brent/Library/Developer/Xcode/DerivedData/ThrowingSegFault-ctdhitedqwltsacnwezxlpqhruzp/Build/Products/Debug -F /Users/brent/Library/Developer/Xcode/DerivedData/ThrowingSegFault-ctdhitedqwltsacnwezxlpqhruzp/Build/Products/Debug -enable-testing -g -import-underlying-module -module-cache-path /Users/brent/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 5 -enforce-exclusivity=checked -Onone -D DEBUG -serialize-debugging-options -enable-anonymous-context-mangled-names -Xcc -I/Users/brent/Library/Developer/Xcode/DerivedData/ThrowingSegFault-ctdhitedqwltsacnwezxlpqhruzp/Build/Intermediates.noindex/ThrowingSegFault.build/Debug/ThrowingSegFault.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/brent/Library/Developer/Xcode/DerivedData/ThrowingSegFault-ctdhitedqwltsacnwezxlpqhruzp/Build/Intermediates.noindex/ThrowingSegFault.build/Debug/ThrowingSegFault.build/ThrowingSegFault-generated-files.hmap -Xcc -I/Users/brent/Library/Developer/Xcode/DerivedData/ThrowingSegFault-ctdhitedqwltsacnwezxlpqhruzp/Build/Intermediates.noindex/ThrowingSegFault.build/Debug/ThrowingSegFault.build/ThrowingSegFault-own-target-headers.hmap -Xcc -I/Users/brent/Library/Developer/Xcode/DerivedData/ThrowingSegFault-ctdhitedqwltsacnwezxlpqhruzp/Build/Intermediates.noindex/ThrowingSegFault.build/Debug/ThrowingSegFault.build/ThrowingSegFault-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/brent/Library/Developer/Xcode/DerivedData/ThrowingSegFault-ctdhitedqwltsacnwezxlpqhruzp/Build/Intermediates.noindex/ThrowingSegFault.build/Debug/ThrowingSegFault.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/brent/Library/Developer/Xcode/DerivedData/ThrowingSegFault-ctdhitedqwltsacnwezxlpqhruzp/Build/Intermediates.noindex/ThrowingSegFault.build/Debug/ThrowingSegFault.build/ThrowingSegFault-project-headers.hmap -Xcc -I/Users/brent/Library/Developer/Xcode/DerivedData/ThrowingSegFault-ctdhitedqwltsacnwezxlpqhruzp/Build/Products/Debug/include -Xcc -I/Users/brent/Library/Developer/Xcode/DerivedData/ThrowingSegFault-ctdhitedqwltsacnwezxlpqhruzp/Build/Intermediates.noindex/ThrowingSegFault.build/Debug/ThrowingSegFault.build/DerivedSources-normal/x86_64 -Xcc -I/Users/brent/Library/Developer/Xcode/DerivedData/ThrowingSegFault-ctdhitedqwltsacnwezxlpqhruzp/Build/Intermediates.noindex/ThrowingSegFault.build/Debug/ThrowingSegFault.build/DerivedSources/x86_64 -Xcc -I/Users/brent/Library/Developer/Xcode/DerivedData/ThrowingSegFault-ctdhitedqwltsacnwezxlpqhruzp/Build/Intermediates.noindex/ThrowingSegFault.build/Debug/ThrowingSegFault.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -ivfsoverlay -Xcc /Users/brent/Library/Developer/Xcode/DerivedData/ThrowingSegFault-ctdhitedqwltsacnwezxlpqhruzp/Build/Intermediates.noindex/ThrowingSegFault.build/Debug/ThrowingSegFault.build/unextended-module-overlay.yaml -Xcc -working-directory/Users/brent/Downloads/ThrowingSegFault -emit-module-doc-path /Users/brent/Library/Developer/Xcode/DerivedData/ThrowingSegFault-ctdhitedqwltsacnwezxlpqhruzp/Build/Intermediates.noindex/ThrowingSegFault.build/Debug/ThrowingSegFault.build/Objects-normal/x86_64/ThrowingSegFault.swiftdoc -emit-objc-header-path /Users/brent/Library/Developer/Xcode/DerivedData/ThrowingSegFault-ctdhitedqwltsacnwezxlpqhruzp/Build/Intermediates.noindex/ThrowingSegFault.build/Debug/ThrowingSegFault.build/Objects-normal/x86_64/ThrowingSegFault-Swift.h -module-name ThrowingSegFault -o /Users/brent/Library/Developer/Xcode/DerivedData/ThrowingSegFault-ctdhitedqwltsacnwezxlpqhruzp/Build/Intermediates.noindex/ThrowingSegFault.build/Debug/ThrowingSegFault.build/Objects-normal/x86_64/ThrowingSegFault.swiftmodule
1. While generating Objective-C header
2. While printing 'Kermit' (in module 'ThrowingSegFault')
0 swift 0x0000000112855105 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1 swift 0x00000001128543f5 llvm::sys::RunSignalHandlers() + 85
2 swift 0x00000001128556e8 SignalHandler(int) + 264
3 libsystem_platform.dylib 0x00007fff624abb1d _sigtramp + 29
4 swift 0x0000000114b7d5c8 cmark_strbuf__initbuf + 128755
5 libsystem_c.dylib 0x00007fff62381a08 abort + 120
6 libsystem_c.dylib 0x00007fff62380cc2 err + 0
7 swift 0x000000011297a103 (anonymous namespace)::ObjCPrinter::printAbstractFunctionAsMethod(swift::AbstractFunctionDecl*, bool, bool) (.cold.14) + 35
8 swift 0x000000010f1f3f75 (anonymous namespace)::ObjCPrinter::printAbstractFunctionAsMethod(swift::AbstractFunctionDecl*, bool, bool) + 4773
9 swift 0x000000010f1f1c20 void (anonymous namespace)::ObjCPrinter::printMembers<false, swift::IteratorRange<swift::DeclIterator> >(swift::IteratorRange<swift::DeclIterator>&&) + 576
10 swift 0x000000010f1eefa8 swift::ASTVisitor<(anonymous namespace)::ObjCPrinter, void, void, void, void, void, void>::visit(swift::Decl*) + 5992
11 swift 0x000000010f1de48d swift::printAsObjC(llvm::raw_ostream&, swift::ModuleDecl*, llvm::StringRef, swift::AccessLevel) + 3725
12 swift 0x000000010f007bc3 void llvm::function_ref<void (llvm::raw_pwrite_stream&)>::callback_fn<swift::withOutputFile(swift::DiagnosticEngine&, llvm::StringRef, llvm::function_ref<bool (llvm::raw_pwrite_stream&)>)::'lambda'(llvm::raw_pwrite_stream&)>(long, llvm::raw_pwrite_stream&) + 19
13 swift 0x000000010fda2a33 swift::atomicallyWritingToFile(llvm::StringRef, llvm::function_ref<void (llvm::raw_pwrite_stream&)>) + 1491
14 swift 0x000000010f007b03 swift::withOutputFile(swift::DiagnosticEngine&, llvm::StringRef, llvm::function_ref<bool (llvm::raw_pwrite_stream&)>) + 83
15 swift 0x000000010f004681 emitAnyWholeModulePostTypeCheckSupplementaryOutputs(swift::CompilerInstance&, swift::CompilerInvocation&, bool) + 257
16 swift 0x000000010f0023b7 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 12439
17 swift 0x000000010effe3fa swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3002
18 swift 0x000000010efa6ea8 main + 696
19 libdyld.dylib 0x00007fff622aa325 start + 1
20 libdyld.dylib 0x0000000000000049 start + 2648005925
error: Abort trap: 6 (in target 'ThrowingSegFault' from project 'ThrowingSegFault') |
AnthonyLatsis
added
CompilerCrash
and removed
crash
Bug: A crash, i.e., an abnormal termination of software
labels
Sep 17, 2022
AnthonyLatsis
added
the
crash
Bug: A crash, i.e., an abnormal termination of software
label
Dec 12, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Attachment: Download
Environment
Xcode 11.2 (11B52)
macOS 10.14.6 (18G103)
Additional Detail from JIRA
md5: 22541a55f4407eedd50576397ec63f1c
Issue Description:
When forgetting the `throws` keyword when conforming to an @objc protocol the compiler segfaults iff the method has a parameter:
Removing the parameter from the function (and protocol) and it compiles. Adding the `throws` to the implementation also works.
A sample project is included for your entertainment pleasure.
crash log:
The text was updated successfully, but these errors were encountered: