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-11717] Property Wrapper Compiler Segfault #54126

Closed
swift-ci opened this issue Nov 6, 2019 · 8 comments
Closed

[SR-11717] Property Wrapper Compiler Segfault #54126

swift-ci opened this issue Nov 6, 2019 · 8 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 property wrappers Feature: property wrappers

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Nov 6, 2019

Previous ID SR-11717
Radar rdar://problem/56926978
Original Reporter chrisballinger (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Xcode 11.2

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

md5: b3cb5c3d3c13607ee0344601b5ed46ff

is duplicated by:

Issue Description:

Attempting to use a workaround for the propertyWrapper enclosing self results in a compiler crash. Using this as a guide: https://github.com/apple/swift-evolution/blob/master/proposals/0258-property-wrappers.md#referencing-the-enclosing-self-in-a-wrapper-type

As well as a snippet of code by iankeen (JIRA User): https://gist.github.com/IanKeen/6c28a0fbd9e51ed108444b0235b3af16

This seems to be the issue:

swift::constraints::ConstraintSystem::resolveOverload(swift::constraints::ConstraintLocator*, swift::Type, swift::constraints::OverloadChoice, swift::DeclContext*) + 341

1. While type-checking getter for state (at /Users/chrisbal/Desktop/TestCrash/TestCrash/ViewController.swift:18:9)
2. While type-checking statement at [/Users/chrisbal/Desktop/TestCrash/TestCrash/ViewController.swift:18:9 - line:18:9] RangeText=""
3. While type-checking statement at [<invalid loc> - <invalid loc>]
4. While type-checking expression at [<invalid loc> - <invalid loc>]
0  swift                    0x000000011233ea13 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x000000011233e1e6 SignalHandler(int) + 358
2  libsystem_platform.dylib 0x00007fff6e462b1d _sigtramp + 29
3  libsystem_platform.dylib 0x0000000400000002 _sigtramp + 2444875010
4  swift                    0x000000010ea32185 swift::constraints::ConstraintSystem::resolveOverload(swift::constraints::ConstraintLocator*, swift::Type, swift::constraints::OverloadChoice, swift::DeclContext*) + 341
5  swift                    0x000000010e9852eb (anonymous namespace)::ConstraintGenerator::addSubscriptConstraints(swift::Expr*, swift::Type, swift::Expr*, swift::ValueDecl*, swift::constraints::ConstraintLocator*) + 2011
6  swift                    0x000000010e97c4c0 (anonymous namespace)::ConstraintWalker::walkToExprPost(swift::Expr*) + 464
7  swift                    0x000000010e976943 swift::constraints::ConstraintSystem::generateConstraints(swift::Expr*, swift::DeclContext*) + 883
8  swift                    0x000000010e9c7ccb swift::constraints::ConstraintSystem::solve(swift::Expr*&, swift::Type, swift::ExprTypeCheckListener*, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 8267
9  swift                    0x000000010eacbaf1 swift::TypeChecker::typeCheckExpressionImpl(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener&, swift::constraints::ConstraintSystem*) + 1041
10 swift                    0x000000010eb7af8e swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 20766
11 swift                    0x000000010eb7c121 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::Stmt>(swift::Stmt*&) + 129
12 swift                    0x000000010eb7bbb3 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 23875
13 swift                    0x000000010eb75e11 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 129
14 swift                    0x000000010eb75910 swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 5456
15 swift                    0x000000010eb7da97 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 519
16 swift                    0x000000010eb9a462 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 2082
17 swift                    0x000000010e28dbdb swift::CompilerInstance::parseAndCheckTypesUpTo(swift::CompilerInstance::ImplicitImports const&, swift::SourceFile::ASTStage_t)::$\_0::operator()(swift::SourceFile&) const + 91
18 swift                    0x000000010e28c93b swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 5371
19 swift                    0x000000010df82216 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 806
20 swift                    0x000000010df7e6e4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6820
21 swift                    0x000000010df0bbe3 main + 1219
22 libdyld.dylib            0x00007fff6e2612e5 start + 1
error: Segmentation fault: 11 (in target 'TestCrash' from project 'TestCrash')
@theblixguy
Copy link
Collaborator

Seems to compile on master without a crash. Can you verify using the latest development (trunk) snapshot?

@theblixguy
Copy link
Collaborator

(by the way, it's a private feature so this is probably expected, but still the compiler shouldn't be crashing)

@swift-ci
Copy link
Collaborator Author

swift-ci commented Nov 6, 2019

Comment by Chris Ballinger (JIRA)

Thanks for the speedy reply! Haven’t configured Xcode to use custom versions of Swift yet, will have to look into that. I’m aware that it’s a private feature but I was just curious if an idea I had would work. 🙂

@beccadax
Copy link
Contributor

beccadax commented Nov 7, 2019

Just using toolchains I happen to have lying around, it seems to have been fixed on master between 9/18 and 9/29.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Nov 7, 2019

Comment by Chris Ballinger (JIRA)

brentdax (JIRA User) Awesome! Would that mean the fix probably got merged into the `swift-5.2-branch`? And if so, if Swift 5.2 will be shipping with Xcode 11.3? I didn't find much info here: https://swift.org/blog/5-2-release-process/

@beccadax
Copy link
Contributor

beccadax commented Nov 7, 2019

Swift 5.2 hasn't branched yet because things are going smoothly, so unless this bug is weirder than it looks, it should be fixed in Swift 5.2. I can't discuss Xcode release schedules, but if you see this in a beta where swift -version says "Apple Swift version 5.2" or later, definitely let us know.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Nov 7, 2019

Comment by Chris Ballinger (JIRA)

Ah ya, no worries, I’ll keep an eye out. Thanks!

@swift-ci
Copy link
Collaborator Author

Comment by Chris Ballinger (JIRA)

I can confirm this is fixed in Swift 5.2 on Xcode 11.4. Would love for this to be made a public API soon!

@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 property wrappers Feature: property wrappers
Projects
None yet
Development

No branches or pull requests

4 participants