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-10160] Seg Fault 11: Attempting to Implicitly convert Tuples #52562

Closed
Mordil opened this issue Mar 23, 2019 · 2 comments
Closed

[SR-10160] Seg Fault 11: Attempting to Implicitly convert Tuples #52562

Mordil opened this issue Mar 23, 2019 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. casting Feature: explicit casting (is, as, as? and as!) compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software

Comments

@Mordil
Copy link

Mordil commented Mar 23, 2019

Previous ID SR-10160
Radar rdar://problem/49241781
Original Reporter @Mordil
Type Bug
Status Resolved
Resolution Duplicate
Environment

macOS Mojave 10.14.4 Beta (18E220a)

Xcode 10.1 (10B61)

Apple Swift version 5.0-dev (LLVM 3207a50965, Clang 107de882f4, Swift 4d6e741)

Target: x86_64-apple-darwin18.5.0

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

md5: f5533e0bb91c26706faf32d1a1427fc8

duplicates:

  • SR-2672 Implement tuple conversion

Issue Description:

The following code causes SourceKit crashes and builds generate a Seg Fault 11

protocol Example { }


extension Int: Example { }


func useExample(_ input: [(Example, Double)]) {
    input.forEach { print($0) }
}


var examples: [(Int, Double)] = []
for index in 1...10 {
    examples.append((index, 0.0))
}


useExample(examples)

Switching

var examples: [(Int, Double)] = []

to

var examples: [(Example, Double)] = []

fixes the issue.

@belkadan
Copy link
Contributor

With assertions on master:

<stdin>:18:1: error: cannot express tuple conversion '(Int, Double)' to '(Example, Double)'
useExample(examples)
^
Assertion failed: (Val && "isa<> used on a null pointer"), function doit, file /Volumes/Data/swift-public/llvm/include/llvm/Support/Casting.h, line 106.
Stack dump:
0.  Program arguments: /Volumes/Data/swift-public/build/ninja/swift-macosx-x86_64/bin/swift -frontend -c -primary-file - -target x86_64-apple-darwin18.5.0 -enable-objc-interop -sdk /Volumes/Data/Applications/Xcode10.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -color-diagnostics -module-name main -o /var/folders/_d/dmrgv26d3bs6lkrks9z825_w0000gn/T/--2899d2.o 
1.  While walking into decl declaration 0x7fc348876910 (at <stdin>:18:1)
0  swift                    0x0000000111f4ca85 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x0000000111f4bd45 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x0000000111f4d068 SignalHandler(int) + 264
3  libsystem_platform.dylib 0x00007fff64bf3b5d _sigtramp + 29
4  swift                    0x000000010f1f95ce (anonymous namespace)::Verifier::walkToExprPost(swift::Expr*) + 11774
5  libsystem_c.dylib        0x00007fff64ab36a6 abort + 127
6  libsystem_c.dylib        0x00007fff64a7c20d basename_r + 0
7  swift                    0x000000010f200d51 (anonymous namespace)::Verifier::maybeRecordValidPointerConversion(swift::Expr*, swift::Expr*)::'lambda'(swift::Expr*)::operator()(swift::Expr*) const + 353
8  swift                    0x000000010f200b6c (anonymous namespace)::Verifier::maybeRecordValidPointerConversion(swift::Expr*, swift::Expr*) + 76
9  swift                    0x000000010f1f62fe (anonymous namespace)::Verifier::walkToExprPre(swift::Expr*) + 1150
10 swift                    0x000000010f20d0d5 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 309
11 swift                    0x000000010f20ee6a swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Decl*) + 234
12 swift                    0x000000010f20a3a7 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 215
13 swift                    0x000000010f20a2bb swift::Decl::walk(swift::ASTWalker&) + 27
14 swift                    0x000000010f2bea4a swift::SourceFile::walk(swift::ASTWalker&) + 170
15 swift                    0x000000010f1f597b swift::verify(swift::SourceFile&) + 59

So it sounds like the verifier needs to be updated to account for this failure case.

@Mordil
Copy link
Author

Mordil commented Mar 25, 2019

Environment:

Apple Swift version 5.0 (swiftlang-1001.0.69.5 clang-1001.0.46.3)

Target: x86_64-apple-darwin18.5.0

Xcode 10.2 (10E125) and the compiler properly warns:

Cannot express tuple conversion '(Int, Double)' to '(Example, Double)'

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added crash Bug: A crash, i.e., an abnormal termination of software casting Feature: explicit casting (is, as, as? and as!) labels 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. casting Feature: explicit casting (is, as, as? and as!) 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

3 participants