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-12999] Assertion failed: (!factory.isOutsideBodyOfFunction(afd) && "Should be inside"), function lookInMembers #55444

Closed
nathawes opened this issue Jun 13, 2020 · 3 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 found by stress tester Flag: An issue found by the SourceKit stress tester

Comments

@nathawes
Copy link
Collaborator

Previous ID SR-12999
Radar rdar://problem/64316115
Original Reporter @nathawes
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, Crash, FoundByStressTester
Assignee None
Priority Medium

md5: 5135d624c3d79c7a7991cce40eba3076

Issue Description:

Compile the below to reproduce. Also crashes sourcekit.

 public final class Foo {
    public var a: String {
        return "\(backgroundContext)"

It's a different assertion, but it seems like it might be related to https://bugs.swift.org/browse/SR-12997. (both have an interpolated string at the end of their source range, so I'm guessing this is due to the interpolation content being past the token-start-based parent end location).

Trace:

Assertion failed: (!factory.isOutsideBodyOfFunction(afd) && "Should be inside"), function lookInMembers, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/AST/UnqualifiedLookup.cpp, line 1261.
 

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff6b42d33a __pthread_kill + 10
1   libsystem_pthread.dylib         0x00007fff6b4e9e60 pthread_kill + 430
2   libsystem_c.dylib               0x00007fff6b3b48a2 __abort + 139
3   libsystem_c.dylib               0x00007fff6b3b4817 abort + 135
4   libsystem_c.dylib               0x00007fff6b3b3ac6 __assert_rtn + 314
5   swift                           0x000000010483c7f3 (anonymous namespace)::ASTScopeDeclConsumerForUnqualifiedLookup::lookInMembers(swift::NullablePtr<swift::DeclContext>, swift::DeclContext*, swift::NominalTypeDecl*, llvm::function_ref<bool (llvm::Optional<bool>)>) (.cold.1) + 35
6   swift                           0x00000001012b434a (anonymous namespace)::ASTScopeDeclConsumerForUnqualifiedLookup::lookInMembers(swift::NullablePtr<swift::DeclContext>, swift::DeclContext*, swift::NominalTypeDecl*, llvm::function_ref<bool (llvm::Optional<bool>)>) + 122
7   swift                           0x00000001010f32aa swift::ast_scope::GenericTypeOrExtensionWhereOrBodyPortion::lookupMembersOf(swift::ast_scope::GenericTypeOrExtensionScope const*, llvm::ArrayRef<swift::ast_scope::ASTScopeImpl const*>, swift::namelookup::AbstractASTScopeDeclConsumer&) const + 122
8   swift                           0x00000001010f2c52 swift::ast_scope::ASTScopeImpl::lookup(llvm::SmallVectorImpl<swift::ast_scope::ASTScopeImpl const*>&, swift::NullablePtr<swift::ast_scope::ASTScopeImpl const>, swift::NullablePtr<swift::GenericParamList const>, swift::namelookup::AbstractASTScopeDeclConsumer&) const + 178
9   swift                           0x00000001010f2724 swift::ast_scope::ASTScopeImpl::unqualifiedLookup(swift::SourceFile*, swift::DeclNameRef, swift::SourceLoc, swift::DeclContext const*, swift::namelookup::AbstractASTScopeDeclConsumer&) + 68
10  swift                           0x00000001010dc8d6 swift::ASTScope::unqualifiedLookup(swift::SourceFile*, swift::DeclNameRef, swift::SourceLoc, swift::DeclContext const*, swift::namelookup::AbstractASTScopeDeclConsumer&) + 86
11  swift                           0x00000001012b334f (anonymous namespace)::UnqualifiedLookupFactory::lookInASTScopes() + 191
12  swift                           0x00000001012b1a64 swift::UnqualifiedLookupRequest::evaluate(swift::Evaluator&, swift::UnqualifiedLookupDescriptor) const + 932
13  swift                           0x00000001012683c3 swift::SimpleRequest<swift::UnqualifiedLookupRequest, swift::LookupResult (swift::UnqualifiedLookupDescriptor), (swift::RequestFlags)25>::evaluateRequest(swift::UnqualifiedLookupRequest const&, swift::Evaluator&) + 35
14  swift                           0x0000000101258762 llvm::Expected<swift::UnqualifiedLookupRequest::OutputType> swift::Evaluator::getResultUncached<swift::UnqualifiedLookupRequest>(swift::UnqualifiedLookupRequest const&) + 354
15  swift                           0x00000001012585a6 llvm::Expected<swift::UnqualifiedLookupRequest::OutputType> swift::Evaluator::operator()<swift::UnqualifiedLookupRequest, (void*)0>(swift::UnqualifiedLookupRequest const&) + 118
16  swift                           0x00000001012583a6 swift::UnqualifiedLookupRequest::OutputType swift::evaluateOrDefault<swift::UnqualifiedLookupRequest>(swift::Evaluator&, swift::UnqualifiedLookupRequest, swift::UnqualifiedLookupRequest::OutputType) + 38
17  swift                           0x0000000100e6baa9 swift::TypeChecker::lookupUnqualified(swift::DeclContext*, swift::DeclNameRef, swift::SourceLoc, swift::OptionSet<swift::NameLookupFlags, unsigned int>) + 185
18  swift                           0x0000000100e17445 swift::TypeChecker::resolveDeclRefExpr(swift::UnresolvedDeclRefExpr*, swift::DeclContext*) + 117
19  swift                           0x0000000100e23df7 (anonymous namespace)::PreCheckExpression::walkToExprPre(swift::Expr*) + 1015
20  swift                           0x00000001010f7c6a swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 202
21  swift                           0x00000001010f9dcf (anonymous namespace)::Traversal::visitApplyExpr(swift::ApplyExpr*) + 207
22  swift                           0x00000001010f9f7b swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Stmt*) + 219
23  swift                           0x00000001010f93e4 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 6212
24  swift                           0x00000001010f8944 swift::ASTVisitor<(anonymous namespace)::Traversal, swift::Expr*, swift::Stmt*, bool, swift::Pattern*, bool, void>::visit(swift::Expr*) + 3492
25  swift                           0x00000001010f75f1 swift::Expr::walk(swift::ASTWalker&) + 81
26  swift                           0x0000000100e1a28c swift::constraints::ConstraintSystem::preCheckExpression(swift::Expr*&, swift::DeclContext*) + 188
27  swift                           0x0000000100e1a595 swift::TypeChecker::typeCheckExpression(swift::constraints::SolutionApplicationTarget&, bool&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 197
28  swift                           0x0000000100e1a437 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 87
29  swift                           0x0000000100ebc923 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 5683
30  swift                           0x0000000100ebce80 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::Stmt>(swift::Stmt*&) + 128
31  swift                           0x0000000100ebbd30 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 2624
32  swift                           0x0000000100eb91c0 bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 128
33  swift                           0x0000000100eb8671 swift::TypeCheckFunctionBodyRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*) const + 1089
34  swift                           0x0000000100ebfb16 llvm::Expected<swift::TypeCheckFunctionBodyRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckFunctionBodyRequest>(swift::TypeCheckFunctionBodyRequest const&) + 598
35  swift                           0x0000000100ebf64c llvm::Expected<swift::TypeCheckFunctionBodyRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckFunctionBodyRequest, (void*)0>(swift::TypeCheckFunctionBodyRequest const&) + 316
36  swift                           0x0000000100ebf4b6 llvm::Expected<swift::TypeCheckFunctionBodyRequest::OutputType> swift::Evaluator::operator()<swift::TypeCheckFunctionBodyRequest, (void*)0>(swift::TypeCheckFunctionBodyRequest const&) + 118
37  swift                           0x0000000100eb7ef5 swift::TypeCheckFunctionBodyRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyRequest, swift::TypeCheckFunctionBodyRequest::OutputType) + 37
38  swift                           0x0000000100eb7ea0 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 64
39  swift                           0x0000000100eebd4e swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 382
40  swift                           0x0000000100eeca65 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 453
41  swift                           0x0000000100eec784 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 52
42  swift                           0x0000000100eec6f6 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::operator()<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) + 118
43  swift                           0x0000000100eebae0 swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 32
44  swift                           0x000000010025c78a swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<void (swift::SourceFile&)>) + 90
45  swift                           0x000000010025c67a swift::CompilerInstance::performSema() + 74
46  swift                           0x000000010017ee19 performCompile(swift::CompilerInstance&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 2329
47  swift                           0x000000010017d519 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3529
48  swift                           0x0000000100119ccd main + 861
49  libdyld.dylib                   0x00007fff6b2e5cc9 start + 1
@nathawes
Copy link
Collaborator Author

@swift-ci create

@typesanitizer
Copy link

Confirming that this reproduces on recent master @ 3455ba9 (Jun 15).

@slavapestov
Copy link
Member

This is already fixed and I added a regression test for it a while ago.

@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 crash Bug: A crash, i.e., an abnormal termination of software found by stress tester Flag: An issue found by the SourceKit stress tester
Projects
None yet
Development

No branches or pull requests

4 participants