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-4141] Segmentation Fault when compiling two functions with default parameters #46724

Closed
ffried opened this issue Mar 2, 2017 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@ffried
Copy link
Contributor

ffried commented Mar 2, 2017

Previous ID SR-4141
Radar None
Original Reporter @ffried
Type Bug
Status Resolved
Resolution Duplicate
Environment

$ swift --version:
Apple Swift version 3.1 (swiftlang-802.0.36.2 clang-802.0.35)
Target: x86_64-apple-macosx10.9

Included in Xcode 8.3 Beta 3 (8W132p)

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

md5: d47b3cabc6ff3b4468db982c5267fe06

duplicates:

  • SR-1076 SILGen crash on overloading functions which take varargs & arrays

Issue Description:

The following code causes Swift (3.0.2 and 3.1) to segfault in silgen emitDefaultArgGenerator SIL function.

func test(with strings: [String], includeAnything: Bool = true) -> String {
    return strings.joined(separator: ",")
}

func test(with strings: String..., includeAnything: Bool = true) -> String {
    return test(with: strings, includeAnything: includeAnything)
}

Removing the default value in either one or both functions still ends up with a segfault.

Here's the stacktrace emitted by swiftc:

$ swiftc EmitDefaultArgGeneratorCrash.swift
0  swift                    0x0000000111cb27a7 PrintStackTraceSignalHandler(void*) + 39
1  swift                    0x0000000111cb1d36 SignalHandler(int) + 662
2  libsystem_platform.dylib 0x00007fffca4e0bba _sigtramp + 26
3  libsystem_platform.dylib 0x00007fad4e8e9000 _sigtramp + 2218820704
4  swift                    0x000000010f6056ee swift::Lowering::SILGenModule::emitAbstractFuncDecl(swift::AbstractFunctionDecl*) + 1086
5  swift                    0x000000010f604e9f swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 31
6  swift                    0x000000010f613a81 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 657
7  swift                    0x000000010f612b3b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 1483
8  swift                    0x000000010f614719 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 1593
9  swift                    0x000000010ef393f2 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 45842
10 swift                    0x000000010eee93c2 main + 11298
11 libdyld.dylib            0x00007fffca2d3255 start + 1
12 libdyld.dylib            0x000000000000000f start + 903007675
Stack dump:
0.  Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file EmitDefaultArgGeneratorCrash.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 EmitDefaultArgGeneratorCrash -o /var/folders/0z/101fmx1n5hl3g6l0vrn5g9qh0000gn/T/EmitDefaultArgGeneratorCrash-2ecac5.o 
1.  While silgen emitDefaultArgGenerator  SIL function @_TIF28EmitDefaultArgGeneratorCrash4testFT4withGSaSS_15includeAnythingSb_SSA0_ for expression at [EmitDefaultArgGeneratorCrash.swift:5:60 - line:5:60] RangeText="t"
<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
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
Projects
None yet
Development

No branches or pull requests

1 participant