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-4088] [Xcode 9 beta1, previously: 8.3 beta] Segmentation fault: 11. While emitting SIL for <member> #46671

Closed
jessesquires opened this issue Feb 27, 2017 · 16 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler crash A crash that happens during compilation compiler The Swift compiler in itself crash Any kind of crash regression SILGen swift 4.0

Comments

@jessesquires
Copy link

Previous ID SR-4088
Radar rdar://problem/32773028
Original Reporter @jessesquires
Type Bug
Status Resolved
Resolution Done
Environment

Xcode Version 9.0 beta (9M136h)

Xcode Version 8.3 beta 3 (8W132p)

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, 3.1Regression, 4.0Regression, CompilerCrash, SILGen
Assignee @jessesquires
Priority Medium

md5: 4d4261cd80bec00a8e1668233eb0c782

Issue Description:

This open source library compiles fine with Xcode 8.2, but seg faults and crashes the compiler with Xcode 8.3. There are at least a few hundred developers using this library.

I don't know enough to give this task a better title/description, so hopefully someone can help with that.

Here's the project with the problem:
https://github.com/jessesquires/JSQDataSourcesKit

Also tracking this issue on GitHub at:
jessesquires/JSQDataSourcesKit#95

Repro steps

Using Xcode Version 8.2.1 (8C1002)

  1. Checkout the develop branch.

  2. Build (cmd-B

  3. Happiness

Using Xcode Version 8.3 beta 3 (8W132p)

  1. Checkout the develop branch.

  2. Build (cmd-B

  3. Cry

Stack trace:

0 swift 0x000000010b0b97a7 PrintStackTraceSignalHandler(void*) + 39
1 swift 0x000000010b0b8d36 SignalHandler(int) + 662
2 libsystem_platform.dylib 0x00007fffaa0f6bba _sigtramp + 26
3 libsystem_platform.dylib 0x00007ff93fd9fa80 _sigtramp + 2513080032
4 swift 0x0000000108e0ebe7 swift::CanType swift::CanTypeVisitor<(anonymous namespace)::SILTypeSubstituter, swift::CanType>::visit<>(swift::CanType) + 375
5 swift 0x0000000108e0f352 (anonymous namespace)::SILTypeSubstituter::visitSILFunctionType(swift::CanTypeWrapper<swift::SILFunctionType>, bool) + 770
6 swift 0x0000000108e0f5b1 swift::SILFunctionType::substGenericArgs(swift::SILModule&, llvm::ArrayRef<swift::Substitution>) + 193
7 swift 0x0000000108a26150 (anonymous namespace)::Callee::getAtUncurryLevel(swift::Lowering::SILGenFunction&, unsigned int) const + 2880
8 swift 0x0000000108a22d90 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 2032
9 swift 0x0000000108a6fb2c swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 124
10 swift 0x0000000108accf14 swift::Lowering::SILGenFunction::emitReturnExpr(swift::SILLocation, swift::Expr*) + 452
11 swift 0x0000000108ac8e7c swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 188
12 swift 0x0000000108acc618 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 14424
13 swift 0x0000000108a8c0c9 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 409
14 swift 0x0000000108a0d52b swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*)::$_1::operator()(swift::SILFunction*) const + 1867
15 swift 0x0000000108a0c102 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 642
16 swift 0x0000000108ad28fa swift::Lowering::SILGenModule::visitExtensionDecl(swift::ExtensionDecl*) + 634
17 swift 0x0000000108a19b3b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 1483
18 swift 0x0000000108a1b719 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 1593
19 swift 0x00000001083403f2 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 45842
20 swift 0x00000001082f03c2 main + 11298
21 libdyld.dylib 0x00007fffa9ee9255 start + 1

@jessesquires
Copy link
Author

/cc @jckarter who knows SIL things
/cc @slavapestov who slays all the crashers 🙂

PS. I think I've added the correct labels, etc. If not, please correct!

@jckarter
Copy link
Member

@swift-ci create

@jckarter
Copy link
Member

I reproed the crash in 8W132p, but it builds successfully in master. I wonder if we fixed this already (we'll want to make sure it gets into 3.1)

@jessesquires
Copy link
Author

Thanks for the update @jckarter!

Do you think the fix will land in the final Xcode 8.3 release?

@jckarter
Copy link
Member

Unfortunately, it still crashes with the latest 3.1 snapshot. Maybe there's a fix we can cherry-pick.

@slavapestov
Copy link
Member

#7887

@jessesquires
Copy link
Author

@slavapestov This is happening again in Xcode9 beta 1 🙁

@jessesquires
Copy link
Author

cc @jckarter too

@slavapestov
Copy link
Member

Reduced test case:

class UITableViewCell {}
class UITableView {}

extension UITableViewCell: ReusableViewProtocol {
    public typealias ParentView = UITableView
}

protocol ReusableViewProtocol {
    associatedtype ParentView
}

protocol ReusableViewFactoryProtocol {
    associatedtype View: ReusableViewProtocol
    func configure(parentView: View.ParentView)
}

extension ReusableViewFactoryProtocol where View: UITableViewCell {
    func tableCellFor(tableView: UITableView) {
        configure(parentView: tableView)
    }
}

If I change "extension ReusableViewFactoryProtocol where View: UITableViewCell" to "extension ReusableViewFactoryProtocol where View == UITableViewCell", no crash. This should be easy to figure out.

@slavapestov
Copy link
Member

Reverting this commit makes it work again:

commit 620db5f74c1ec57d832814ebf3811ca1bb4262ce
Author: Slava Pestov <spestov@apple.com>
Date:   Sat Apr 22 01:29:08 2017 -0700

    AST: Narrower workaround for "concrete conformance under abstract conformance" bug
    
    Instead of just falling back to module lookup any time conformance
    substitution fails, only do it in the case we know doesn't work.
    
    This should shake out some more bugs, hopefully without causing
    too much pain.

@slavapestov
Copy link
Member

4.0 PR: #10440

@lplarson
Copy link
Member

Resolved on 4.0 and master.

@jckarter
Copy link
Member

@jessesquires Can you confirm whether this works with a recent snapshot toolchain? The fix should roll out in a future Xcode 9 seed too if you want to wait for that.

@jessesquires
Copy link
Author

@jckarter Will do!

@jessesquires
Copy link
Author

Confirming that this is fixed with the Swift 4.0 snapshot from 7/7/17 😃

cc @jckarter @slavapestov @lplarson

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Any kind of crash 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 crash A crash that happens during compilation compiler The Swift compiler in itself crash Any kind of crash regression SILGen swift 4.0
Projects
None yet
Development

No branches or pull requests

5 participants