Skip to content
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

Crash when compiling any RangeExpression & Sendable in some cases #63878

Open
rnapier opened this issue Feb 24, 2023 · 1 comment
Open

Crash when compiling any RangeExpression & Sendable in some cases #63878

rnapier opened this issue Feb 24, 2023 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself crash Bug: A crash, i.e., an abnormal termination of software existentials Feature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased values IRGen LLVM IR generation protocol compositions Feature → types: protocol composition types swift 5.8

Comments

@rnapier
Copy link

rnapier commented Feb 24, 2023

Description

The following code crashes the compiler. I believe this is a minimal example (reworking various lines make the crash go away). If Sendable is replaced by an empty protocol P{}, it also crashes, but not if it is replaced by CustomStringConvertible. Note the RangeExpression without a Bound type.

Steps to reproduce

struct Period {
    var monthsBad: any RangeExpression & Sendable
    public typealias IntRangeSendable = RangeExpression<Int> & Sendable
    var monthsGood: any IntRangeSendable
}

Expected behavior

Should not crash. Following is the crash stack:

error: compile command failed due to signal 11 (use -v to see invocation)
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Applications/Xcode-14.3.0-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file main.swift -target arm64-apple-macosx13.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode-14.3.0-Beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -color-diagnostics -new-driver-path /Applications/Xcode-14.3.0-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /Applications/Xcode-14.3.0-Beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -module-name main -disable-clang-spi -target-sdk-version 13.3 -target-sdk-name macosx13.3 -o /var/folders/zs/gg0pzfwd0851ltpw5gjwl5gm0000gn/T/TemporaryDirectory.jEPPp8/main-1.o
1.	Apple Swift version 5.8 (swiftlang-5.8.0.117.11 clang-1403.0.22.8.60)
2.	Compiling with the current language version
3.	While evaluating request IRGenRequest(IR Generation for file "main.swift")
4.	While emitting IR SIL function "@$s4main6PeriodV10monthsGoodSX_AA1Ppvg".
 for getter for monthsGood (at main.swift:5:9)
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x0000000108004170 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000108003154 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000108004780 SignalHandler(int) + 344
3  libsystem_platform.dylib 0x0000000181a742a4 _sigtramp + 56
4  libsystem_platform.dylib 0xffff800102f6133c _sigtramp + 18446603334095655120
5  swift-frontend           0x0000000102f60c14 llvm::IRBuilderBase::CreateCall(llvm::FunctionType*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&, llvm::MDNode*) + 80
6  swift-frontend           0x00000001034b3a88 swift::irgen::OutliningMetadataCollector::emitCallToOutlinedCopy(swift::irgen::Address, swift::irgen::Address, swift::SILType, swift::irgen::TypeInfo const&, swift::IsInitialization_t, swift::IsTake_t) const + 3184
7  swift-frontend           0x0000000103335b78 (anonymous namespace)::OpaqueExistentialTypeInfo::initializeWithCopy(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, bool) const + 644
8  swift-frontend           0x000000010345dd14 (anonymous namespace)::IRGenSILFunction::visitSILBasicBlock(swift::SILBasicBlock*) + 55964
9  swift-frontend           0x000000010344e84c swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 10696
10 swift-frontend           0x00000001032d8ac4 swift::irgen::IRGenerator::emitGlobalTopLevel(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > const&) + 1704
11 swift-frontend           0x0000000103402af0 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 10976
12 swift-frontend           0x000000010344bbb8 swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 188
13 swift-frontend           0x0000000103414144 llvm::Expected<swift::IRGenRequest::OutputType> swift::Evaluator::getResultUncached<swift::IRGenRequest>(swift::IRGenRequest const&) + 832
14 swift-frontend           0x0000000103405e54 swift::performIRGeneration(swift::FileUnit*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::GlobalVariable**) + 236
15 swift-frontend           0x0000000102f00abc generateIR(swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, llvm::GlobalVariable*&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >) + 228
16 swift-frontend           0x0000000102efb31c performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 1684
17 swift-frontend           0x0000000102efe0ac performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1856
18 swift-frontend           0x0000000102efc4d0 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4324
19 swift-frontend           0x0000000102ec1378 swift::mainEntry(int, char const**) + 4116
20 dyld                     0x000000018171be50 start + 2544

Environment
swift-driver version: 1.75.1 Apple Swift version 5.8 (swiftlang-5.8.0.117.11 clang-1403.0.22.8.60)
Target: arm64-apple-macosx13.0

Xcode 14.3
Build version 14E5197f

Target: macOS 13.2.1

@rnapier rnapier added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Feb 24, 2023
@AnthonyLatsis AnthonyLatsis added compiler The Swift compiler itself IRGen LLVM IR generation compiler crash crash Bug: A crash, i.e., an abnormal termination of software protocol compositions Feature → types: protocol composition types swift 5.8 and removed triage needed This issue needs more specific labels labels Feb 24, 2023
@AnthonyLatsis
Copy link
Collaborator

Can you try the latest 5.8 and trunk development snapshots? No crash with a recent 5.9-dev compiler.

@AnthonyLatsis AnthonyLatsis added the existentials Feature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased values label Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself crash Bug: A crash, i.e., an abnormal termination of software existentials Feature: values of types like `any Collection`, `Any` and `AnyObject`; type-erased values IRGen LLVM IR generation protocol compositions Feature → types: protocol composition types swift 5.8
Projects
None yet
Development

No branches or pull requests

2 participants