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-3866] LLVM error when using a parameter as a default value of nested function #46451

Closed
rintaro mannequin opened this issue Feb 6, 2017 · 0 comments
Closed

[SR-3866] LLVM error when using a parameter as a default value of nested function #46451

rintaro mannequin opened this issue Feb 6, 2017 · 0 comments
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

Comments

@rintaro
Copy link
Mannequin

rintaro mannequin commented Feb 6, 2017

Previous ID SR-3866
Radar None
Original Reporter @rintaro
Type Bug
Status Closed
Resolution Duplicate
Environment

Xcode Version 8.3 beta (8W109m)
Apple Swift version 3.0 (swiftlang-802.0.27.2 clang-802.0.27.2)
Target: x86_64-apple-macosx10.9

Xcode 8.2.1

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

md5: fa575dae85c7ae5d3fa7659dad57432e

duplicates:

  • SR-2189 Nested function with local default value crashes

Issue Description:

func foo(x: Int) {
    func inner(y: Int = x) {
        print(y)
    }
    inner()
}

foo(x: 12)

results:

$ swiftc testcapture.swift 
Global is external, but doesn't have external or weak linkage!
i8* ()* @_TFF11testcapture3fooFT1xSi_T_auL_1xSi
LLVM ERROR: Broken module found, compilation aborted!

I'm not sure how this should be handled.

This also crashes, but in the SILGen.

func foo(x: Int) {
    func inner(y: Int = { x }()) {
        print(y)
    }
    inner()
}

foo(x: 12)
0  swift                    0x000000010d146677 PrintStackTraceSignalHandler(void*) + 39
1  swift                    0x000000010d145b26 SignalHandler(int) + 646
2  libsystem_platform.dylib 0x00007fffa089bbba _sigtramp + 26
3  libsystem_platform.dylib 0x00007fa34c817d00 _sigtramp + 2885140832
4  swift                    0x000000010a2594a5 (anonymous namespace)::SILGenApply::visitAbstractClosureExpr(swift::AbstractClosureExpr*) + 869
5  swift                    0x000000010a25a0d2 (anonymous namespace)::SILGenApply::visitApplyExpr(swift::ApplyExpr*) + 1186
6  swift                    0x000000010a24a317 prepareApplyExpr(swift::Lowering::SILGenFunction&, swift::Expr*) + 263
7  swift                    0x000000010a297f10 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 112
8  swift                    0x000000010a2f5c93 swift::Lowering::SILGenFunction::emitReturnExpr(swift::SILLocation, swift::Expr*) + 467
9  swift                    0x000000010a2b7901 swift::Lowering::SILGenFunction::emitGeneratorFunction(swift::SILDeclRef, swift::Expr*) + 737
10 swift                    0x000000010a234c77 swift::Lowering::SILGenModule::emitAbstractFuncDecl(swift::AbstractFunctionDecl*) + 1767
11 swift                    0x000000010a23417f swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 31
12 swift                    0x000000010a2f54ce swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 14750
13 swift                    0x000000010a2b4989 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 409
14 swift                    0x000000010a23580b swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*)::$_1::operator()(swift::SILFunction*) const + 1867
15 swift                    0x000000010a2343e2 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 642
16 swift                    0x000000010a242e61 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 657
17 swift                    0x000000010a241ecb swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 1659
18 swift                    0x000000010a243af9 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 1593
19 swift                    0x000000010a067c58 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 42392
20 swift                    0x000000010a0174bc main + 9052
21 libdyld.dylib            0x00007fffa068e255 start + 1
22 libdyld.dylib            0x000000000000000f start + 1603739067
Stack dump:
0.  Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file testcapture.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk -color-diagnostics -module-name testcapture -o /var/folders/y0/845byh512k53x98tw3ch5j2w0000gn/T/testcapture-50dace.o 
1.  While emitting SIL for 'foo' at testcapture.swift:1:1
2.  While silgen emitDefaultArgGenerator  SIL function @_TIFF11testcapture3fooFT1xSi_T_L_5innerFT1ySi_T_A_ for expression at [testcapture.swift:2:23 - line:2:27] RangeText="{x}()"
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
@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
Projects
None yet
Development

No branches or pull requests

1 participant