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

[SR-9159] case let as when switching a function causes segfault #51654

Closed
swift-ci opened this issue Nov 2, 2018 · 4 comments
Closed

[SR-9159] case let as when switching a function causes segfault #51654

swift-ci opened this issue Nov 2, 2018 · 4 comments

Comments

@swift-ci
Copy link
Collaborator

@swift-ci swift-ci commented Nov 2, 2018

Previous ID SR-9159
Radar rdar://problem/45962466
Original Reporter voxar (JIRA User)
Type Bug
Status Closed
Resolution Done
Environment

Standard App Store Xcode 10.1 installation on OS X 10.14 (18A391)

$swiftc --version
{{ Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1)Target: x86_64-apple-darwin18.0.0}}

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, SILGen
Assignee None
Priority Medium

md5: ac2b5234363d3d1679981ffae99457b1

Issue Description:

The following code causes a segmentation fault

func hello() {}
switch hello { 
  case let a as Any: print(a)
}
0 swift 0x0000000107cd659a PrintStackTraceSignalHandler(void*) + 42
1 swift 0x0000000107cd5d4e SignalHandler(int) + 302
2 libsystem_platform.dylib 0x00007fff5855bb3d _sigtramp + 29
3 libsystem_platform.dylib 0x00007feeb1e40238 _sigtramp + 1502496536
4 swift 0x00000001054d1769 llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::callback_fn<swift::Type::transform(llvm::function_ref<swift::Type (swift::Type)>) const::$_15>(long, swift::TypeBase*) + 25
5 swift 0x00000001054d17d8 swift::Type::transformRec(llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>) const + 56
6 swift 0x000000010419a83c swift::irgen::IRGenFunction::emitTypeMetadataRef(swift::CanType, swift::irgen::DynamicMetadataRequest) + 76
7 swift 0x000000010419a5d2 (anonymous namespace)::EmitTypeMetadataRef::visitAnyMetatypeType(swift::CanTypeWrapper<swift::AnyMetatypeType>, swift::irgen::DynamicMetadataRequest) + 130
8 swift 0x0000000104196fb3 emitDirectTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanType, swift::irgen::DynamicMetadataRequest) + 339
9 swift 0x0000000104196e44 swift::irgen::MetadataResponse llvm::function_ref<swift::irgen::MetadataResponse (swift::irgen::IRGenFunction&, swift::irgen::DynamicMetadataRequest, llvm::Constant*)>::callback_fn<swift::irgen::getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t)::$_2>(long, swift::irgen::IRGenFunction&, swift::irgen::DynamicMetadataRequest, llvm::Constant*) + 500
10 swift 0x0000000104196c39 swift::irgen::MetadataResponse llvm::function_ref<swift::irgen::MetadataResponse (swift::irgen::IRGenFunction&, swift::irgen::Explosion&)>::callback_fn<swift::irgen::getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t, llvm::function_ref<swift::irgen::MetadataResponse (swift::irgen::IRGenFunction&, swift::irgen::DynamicMetadataRequest, llvm::Constant*)>)::$_1>(long, swift::irgen::IRGenFunction&, swift::irgen::Explosion&) + 89
11 swift 0x0000000104195210 swift::irgen::emitLazyCacheAccessFunction(swift::irgen::IRGenModule&, llvm::Function*, llvm::GlobalVariable*, llvm::function_ref<swift::irgen::MetadataResponse (swift::irgen::IRGenFunction&, swift::irgen::Explosion&)>, bool) + 1504
12 swift 0x0000000104196bca swift::irgen::getTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::ForDefinition_t, llvm::function_ref<swift::irgen::MetadataResponse (swift::irgen::IRGenFunction&, swift::irgen::DynamicMetadataRequest, llvm::Constant*)>) + 506
13 swift 0x000000010419aa32 emitCallToTypeMetadataAccessFunction(swift::irgen::IRGenFunction&, swift::CanType, swift::irgen::DynamicMetadataRequest, swift::ForDefinition_t) + 114
14 swift 0x000000010419a8c3 swift::irgen::IRGenFunction::emitTypeMetadataRef(swift::CanType, swift::irgen::DynamicMetadataRequest) + 211
15 swift 0x000000010419d956 swift::irgen::emitMetatypeRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::MetatypeType>, swift::irgen::Explosion&) + 102
16 swift 0x00000001041530de swift::SILInstructionVisitor<(anonymous namespace)::IRGenSILFunction, void>::visit(swift::SILInstruction*) + 38958
17 swift 0x0000000104146d41 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 9825
18 swift 0x0000000104028910 swift::irgen::IRGenerator::emitGlobalTopLevel(bool) + 1184
19 swift 0x0000000104127386 performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, swift::SourceFile*, llvm::GlobalVariable**, unsigned int) + 1382
20 swift 0x00000001041241b7 swift::performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule> >, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::LLVMContext&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, llvm::GlobalVariable**) + 727
21 swift 0x0000000103f67d80 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 47952
22 swift 0x0000000103f58d35 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7717
23 swift 0x0000000103efe965 main + 1349
24 libdyld.dylib 0x00007fff58372085 start + 1
25 libdyld.dylib 0x0000000000000009 start + 2814959493
Stack dump:
0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret untitled 2 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -module-name untitled_7j 
1. While emitting IR SIL function "@main".
@belkadan
Copy link
Contributor

@belkadan belkadan commented Nov 2, 2018

On master:

Assertion failed: (operand.getType().isAddress()), function emitConditional, file /Volumes/Data/swift-public/swift/lib/SILGen/SILGenDynamicCast.cpp, line 391.

7  swift                    0x000000010e829b52 swift::Lowering::SILGenFunction::emitCheckedCastBranchOld(swift::SILLocation, swift::Lowering::ConsumableManagedValue, swift::Type, swift::CanType, swift::Lowering::SGFContext, llvm::function_ref<void (swift::Lowering::ManagedValue)>, llvm::function_ref<void ()>, swift::ProfileCounter, swift::ProfileCounter) + 2802
8  swift                    0x000000010e87dee9 (anonymous namespace)::PatternMatchEmission::emitSpecializedDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, unsigned int&, unsigned int, std::__1::function<void (swift::SILLocation)> const&) + 7193
9  swift                    0x000000010e878b6d (anonymous namespace)::PatternMatchEmission::emitDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, std::__1::function<void (swift::SILLocation)> const&) + 1997
10 swift                    0x000000010e877cef swift::Lowering::SILGenFunction::emitSwitchStmt(swift::SwitchStmt*) + 2735

@swift-ci create

@slavapestov
Copy link
Member

@slavapestov slavapestov commented Nov 16, 2018

@AnnaZaks
Copy link
Mannequin

@AnnaZaks AnnaZaks mannequin commented Jul 23, 2019

voxar (JIRA User), Could you verify if the problem is fixed and if so move the JIRA to "Closed"?

Thanks!
Anna

@swift-ci
Copy link
Collaborator Author

@swift-ci swift-ci commented Jul 23, 2019

Comment by Patrik Sjöberg (JIRA)

Hi, sorry I've been on vacation 🙂

Confirm, looks good in xcode 10.2.1

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants