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-3267] Segmentation Fault while converting ()->Void to ()->Any #45855

Closed
swift-ci opened this issue Nov 23, 2016 · 4 comments
Closed

[SR-3267] Segmentation Fault while converting ()->Void to ()->Any #45855

swift-ci opened this issue Nov 23, 2016 · 4 comments
Assignees
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 SILGen Area → compiler: The SIL generation stage

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-3267
Radar None
Original Reporter scoot (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode8.1/Swift3.0.1

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

md5: 066644c99144b513766ad5277b42cbf3

Issue Description:

This code causes compiler error on macOS and Linux.

let function: () -> Any = { () -> Void in }
0  swift                    0x0000000109e08a3d PrintStackTraceSignalHandler(void*) + 45
1  swift                    0x0000000109e08466 SignalHandler(int) + 470
2  libsystem_platform.dylib 0x00007fff9fc4dbba _sigtramp + 26
3  libsystem_platform.dylib 0x00007fff58abb8d8 _sigtramp + 3102137656
4  swift                    0x00000001074090a3 (anonymous namespace)::ResultPlanner::planTupleIntoIndirectResult(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::TupleType>, swift::Lowering::AbstractionPattern, swift::CanType, (anonymous namespace)::ResultPlanner::PlanData&, swift::SILValue) + 1603
5  swift                    0x00000001074074f3 (anonymous namespace)::ResultPlanner::plan(swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern, swift::CanType, (anonymous namespace)::ResultPlanner::PlanData&) + 1123
6  swift                    0x0000000107405835 createThunk(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::TypeLowering const&) + 2405
7  swift                    0x0000000107402cd9 (anonymous namespace)::Transform::transform(swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::SGFContext) + 1897
8  swift                    0x00000001073c8929 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 59513
9  swift                    0x00000001073b9f43 swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*) + 195
10 swift                    0x00000001073a7603 swift::Lowering::SILGenFunction::emitPatternBinding(swift::PatternBindingDecl*, unsigned int) + 195
11 swift                    0x000000010735e90d swift::ASTVisitor<swift::Lowering::SILGenFunction, void, void, void, void, void, void>::visit(swift::Decl*) + 125
12 swift                    0x000000010736033a swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 2138
13 swift                    0x0000000107361e9d swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 1629
14 swift                    0x00000001071b5bb9 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 19513
15 swift                    0x00000001071aef70 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 17856
16 swift                    0x000000010716b93e main + 8302
17 libdyld.dylib            0x00007fff9fa41255 start + 1
18 libdyld.dylib            0x000000000000000f start + 1616637371
Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file main.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -color-diagnostics -module-name main -o /var/folders/jr/p08kmfxd3y9356d7kl_tlvw00000gn/T/main-002bdc.o 
1.  While emitting reabstraction thunk in SIL function @_TTRXFo___XFo__iP__<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
@jtbandes
Copy link
Collaborator

This no longer crashes on the master branch. I'm adding it as a regression test: #5915

@jtbandes
Copy link
Collaborator

Sorry, I was mistaken, it still crashes. I just forgot to use -emit-silgen.

@belkadan
Copy link
Contributor

belkadan commented Dec 9, 2016

Assertion failed: (isa<TupleType>(innerSubstType) == isa<TupleType>(outerSubstType) || (isa<TupleType>(innerSubstType) && outerSubstType->getAnyOptionalObjectType())), function plan, file /Volumes/Data/swift-public/swift/lib/SILGen/SILGenPoly.cpp, line 1649.

The AST looks okay, so tagging as SILGen.

      (pattern_binding_decl
        (pattern_typed type='() -> Any'
          (pattern_named type='() -> Any' 'function')
          (type_function
            (type_tuple)
            (type_composite)))
        (function_conversion_expr implicit type='() -> Any' location=<stdin>:1:27 range=[<stdin>:1:27 - line:1:43]
          (closure_expr type='() -> Void' location=<stdin>:1:27 range=[<stdin>:1:27 - line:1:43] discriminator=0
            (parameter_list)
            (brace_stmt))))

@slavapestov
Copy link
Member

#6483

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis 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 SILGen Area → compiler: The SIL generation stage
Projects
None yet
Development

No branches or pull requests

5 participants