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-8764] IR SIL generation failed for applyWrapped function in Swift4 Xcode 10 #51272
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
crash
Bug: A crash, i.e., an abnormal termination of software
regression
swift 4.2
Comments
This is definitely a bug, the compiler should never crash. With assertions (on master): Assertion failed: (Base->getType().isLoweringOf( getModule(), MetatypeTy.castTo<MetatypeType>().getInstanceType()) && "value_metatype result must be formal metatype of the lowered operand " "type"), function createValueMetatype, file /Users/Hamish/Desktop/swift-dev/swift/lib/SIL/SILBuilder.cpp, line 499. Stack dump:
0. Program arguments: ./swift -frontend -c /Users/Hamish/Desktop/Stochastic Projects/newplayground/newplayground/main.swift
1. While emitting SIL for 'applyWrapped(function:to:)' at /Users/Hamish/Desktop/Stochastic Projects/newplayground/newplayground/main.swift:239:27
2. While silgen emitFunction SIL function "@$S4main12applyWrapped8function2toq_Sgq_xcSg_xSgtr0_lF".
for 'applyWrapped(function:to:)' at /Users/Hamish/Desktop/Stochastic Projects/newplayground/newplayground/main.swift:239:27
0 swift 0x000000011042c798 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1 swift 0x000000011042b768 llvm::sys::RunSignalHandlers() + 248
2 swift 0x000000011042cdb2 SignalHandler(int) + 258
3 libsystem_platform.dylib 0x00007fff7bd01f5a _sigtramp + 26
4 libsystem_platform.dylib 0x0000000000003e38 _sigtramp + 2217746168
5 libsystem_c.dylib 0x00007fff7ba9f1ae abort + 127
6 libsystem_c.dylib 0x00007fff7ba671ac basename_r + 0
7 swift 0x000000010d3a2bb3 swift::SILBuilder::createValueMetatype(swift::SILLocation, swift::SILType, swift::SILValue) + 547
8 swift 0x000000010cdedc51 swift::Lowering::SILGenBuilder::createValueMetatype(swift::SILLocation, swift::SILType, swift::Lowering::ManagedValue) + 33
9 swift 0x000000010ce71ad5 std::__1::__function::__func<swift::Lowering::SILGenFunction::emitSwitchStmt(swift::SwitchStmt*)::$_1, std::__1::allocator<swift::Lowering::SILGenFunction::emitSwitchStmt(swift::SwitchStmt*)::$_1>, void (swift::SILLocation)>::operator()(swift::SILLocation&&) + 1157
10 swift 0x000000010ce6b5c2 std::__1::__function::__func<(anonymous namespace)::PatternMatchEmission::emitDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, std::__1::function<void (swift::SILLocation)> const&)::$_4, std::__1::allocator<(anonymous namespace)::PatternMatchEmission::emitDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, std::__1::function<void (swift::SILLocation)> const&)::$_4>, void (swift::SILLocation)>::operator()(swift::SILLocation&&) + 98
11 swift 0x000000010ce6b5c2 std::__1::__function::__func<(anonymous namespace)::PatternMatchEmission::emitDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, std::__1::function<void (swift::SILLocation)> const&)::$_4, std::__1::allocator<(anonymous namespace)::PatternMatchEmission::emitDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, std::__1::function<void (swift::SILLocation)> const&)::$_4>, void (swift::SILLocation)>::operator()(swift::SILLocation&&) + 98
12 swift 0x000000010ce68ada (anonymous namespace)::PatternMatchEmission::emitSpecializedDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, unsigned int&, unsigned int, std::__1::function<void (swift::SILLocation)> const&) + 5226
13 swift 0x000000010ce63f0d (anonymous namespace)::PatternMatchEmission::emitDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, std::__1::function<void (swift::SILLocation)> const&) + 1981
14 swift 0x000000010ce6c1c9 std::__1::__function::__func<(anonymous namespace)::PatternMatchEmission::emitSpecializedDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, unsigned int&, unsigned int, std::__1::function<void (swift::SILLocation)> const&)::$_5, std::__1::allocator<(anonymous namespace)::PatternMatchEmission::emitSpecializedDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, unsigned int&, unsigned int, std::__1::function<void (swift::SILLocation)> const&)::$_5>, void (llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, llvm::ArrayRef<(anonymous namespace)::SpecializedRow>, std::__1::function<void (swift::SILLocation)> const&)>::operator()(llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>&&, llvm::ArrayRef<(anonymous namespace)::SpecializedRow>&&, std::__1::function<void (swift::SILLocation)> const&) + 1945
15 swift 0x000000010ce6a24b (anonymous namespace)::PatternMatchEmission::emitSpecializedDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, unsigned int&, unsigned int, std::__1::function<void (swift::SILLocation)> const&) + 11227
16 swift 0x000000010ce63f0d (anonymous namespace)::PatternMatchEmission::emitDispatch((anonymous namespace)::ClauseMatrix&, llvm::ArrayRef<swift::Lowering::ConsumableManagedValue>, std::__1::function<void (swift::SILLocation)> const&) + 1981
17 swift 0x000000010ce6309f swift::Lowering::SILGenFunction::emitSwitchStmt(swift::SwitchStmt*) + 2735
18 swift 0x000000010ce8c08b swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 8155
19 swift 0x000000010ce8a0a5 swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 21
20 swift 0x000000010ce430a9 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 425
21 swift 0x000000010cdbb08d swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*)::$_1::operator()(swift::SILFunction*) const + 237
22 swift 0x000000010cdb2197 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 631
23 swift 0x000000010cdb7544 swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 820
24 swift 0x000000010cdb83b5 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool) + 421
25 swift 0x000000010cdb88e8 swift::performSILGeneration(swift::ModuleDecl*, swift::SILOptions&, bool) + 24
26 swift 0x000000010c5c95d6 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 9542
27 swift 0x000000010c5c5ffd swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3021
28 swift 0x000000010c57815e main + 686
29 libdyld.dylib 0x00007fff7b9f3015 start + 1
fish: 'and ./swift -frontend -c /Users…' terminated by signal SIGABRT (Abort) |
You can work around the crash by rewriting it this way for now:
|
No longer crashes on master, so I'm adding a regression test. |
AnthonyLatsis
added
the
crash
Bug: A crash, i.e., an abnormal termination of software
label
Dec 12, 2022
This issue was closed.
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 in itself
crash
Bug: A crash, i.e., an abnormal termination of software
regression
swift 4.2
Additional Detail from JIRA
md5: 58adac2b9e39119e52b1ae08d095f9de
is duplicated by:
Issue Description:
This is the function that caused the seg fault in entirety.
I tried in playgrounds and in single view app with this code in VC. Both have the same seg fault.
This code is used in our production code now using Xcode 9.2. Is there something that I am missing or is it a real compiler bug?
The text was updated successfully, but these errors were encountered: