Skip to content

[swiftc] Add test case for crash triggered in swift::TypeChecker::validateDecl(…) #1643

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

Merged
merged 1 commit into from
Mar 12, 2016
Merged

[swiftc] Add test case for crash triggered in swift::TypeChecker::validateDecl(…) #1643

merged 1 commit into from
Mar 12, 2016

Conversation

practicalswift
Copy link
Contributor

What's in this pull request?

Crash case with stack trace:

swift: /path/to/swift/lib/Sema/TypeCheckDecl.cpp:6379: void swift::TypeChecker::validateDecl(swift::ValueDecl *, bool): Assertion `gp->getOuterParameters() == proto->getDeclContext()->getGenericParamsOfContext()' failed.
8  swift           0x0000000000e417fe swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 7134
9  swift           0x000000000107b82c swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, unsigned int, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 3612
10 swift           0x0000000001079ef0 swift::UnqualifiedLookup::UnqualifiedLookup(swift::DeclName, swift::DeclContext*, swift::LazyResolver*, bool, swift::SourceLoc, bool, bool) + 2384
11 swift           0x0000000000e7f38b swift::TypeChecker::lookupUnqualified(swift::DeclContext*, swift::DeclName, swift::SourceLoc, swift::OptionSet<swift::NameLookupFlags, unsigned int>) + 187
14 swift           0x0000000000eaa10e swift::TypeChecker::resolveIdentifierType(swift::DeclContext*, swift::IdentTypeRepr*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, bool, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 158
16 swift           0x0000000000eab024 swift::TypeChecker::resolveType(swift::TypeRepr*, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 164
17 swift           0x0000000000eaa00a swift::TypeChecker::validateType(swift::TypeLoc&, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 42
18 swift           0x0000000000f623af swift::IterativeTypeChecker::processResolveInheritedClauseEntry(std::pair<llvm::PointerUnion<swift::TypeDecl*, swift::ExtensionDecl*>, unsigned int>, llvm::function_ref<bool (swift::TypeCheckRequest)>) + 159
19 swift           0x0000000000f40d3d swift::IterativeTypeChecker::satisfy(swift::TypeCheckRequest) + 493
20 swift           0x0000000000e3c9f9 swift::TypeChecker::resolveInheritanceClause(llvm::PointerUnion<swift::TypeDecl*, swift::ExtensionDecl*>) + 137
21 swift           0x0000000000e4015b swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 1339
22 swift           0x0000000000e3fcf1 swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 209
25 swift           0x0000000001073202 swift::namelookup::lookupInModule(swift::ModuleDecl*, llvm::ArrayRef<std::pair<swift::Identifier, swift::SourceLoc> >, swift::DeclName, llvm::SmallVectorImpl<swift::ValueDecl*>&, swift::NLKind, swift::namelookup::ResolutionKind, swift::LazyResolver*, swift::DeclContext const*, llvm::ArrayRef<std::pair<llvm::ArrayRef<std::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*> >) + 1122
26 swift           0x000000000107a52a swift::UnqualifiedLookup::UnqualifiedLookup(swift::DeclName, swift::DeclContext*, swift::LazyResolver*, bool, swift::SourceLoc, bool, bool) + 3978
27 swift           0x0000000000e7f38b swift::TypeChecker::lookupUnqualified(swift::DeclContext*, swift::DeclName, swift::SourceLoc, swift::OptionSet<swift::NameLookupFlags, unsigned int>) + 187
30 swift           0x0000000000e88c60 swift::TypeChecker::inferDefaultWitnesses(swift::ProtocolDecl*) + 288
31 swift           0x0000000000e69318 swift::finishTypeChecking(swift::SourceFile&) + 536
32 swift           0x0000000000cbb88a swift::CompilerInstance::performSema() + 3514
34 swift           0x000000000078ad8b frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2523
35 swift           0x0000000000785835 main + 2837
Stack dump:
0.  Program arguments: /path/to/swift/bin/swift -frontend -c -primary-file validation-test/compiler_crashers/28263-swift-typechecker-validatedecl.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -module-name main -o /tmp/28263-swift-typechecker-validatedecl-5db636.o
1.  While resolving type c at [validation-test/compiler_crashers/28263-swift-typechecker-validatedecl.swift:14:13 - line:14:13] RangeText="c"
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)

Resolved bug number: –


Before merging this pull request to apple/swift repository:

  • Test pull request on Swift continuous integration.

Triggering Swift CI

The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:

Smoke Testing

Platform Comment
All supported platforms @swift-ci Please smoke test
OS X platform @swift-ci Please smoke test OS X platform
Linux platform @swift-ci Please smoke test Linux platform

Validation Testing

Platform Comment
All supported platforms @swift-ci Please test
OS X platform @swift-ci Please test OS X platform
Linux platform @swift-ci Please test Linux platform

Note: Only members of the Apple organization can trigger swift-ci.

// RUN: not --crash %target-swift-frontend %s -parse
// REQUIRES: asserts

// Distributed under the terms of the MIT license
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All code contributed to Swift is under the Apache 2 license. Is there a reason to include this MIT license comment?

@tkremenek
Copy link
Member

@practicalswift Nevermind. It appears that the test suite is full of tests with the MIT license disclaimer. We probably should have a discussion on swift-dev about what we want to do here, if anything, as the intent was that the entire codebase was under one license.

@tkremenek
Copy link
Member

@swift-ci Please test

@tkremenek tkremenek self-assigned this Mar 11, 2016
@practicalswift
Copy link
Contributor Author

@tkremenek These crashes are imported from https://github.com/practicalswift/swift-compiler-crashes which use the MIT license due to historical reasons (the choice of license predates the open sourcing of Swift), but I'm more than happy to dual-license all my files under both Apache 2 and MIT if that would help :-)

Perhaps I should simply s/MIT license/Apache 2/ in all upcoming compiler crashes contributions?

What is the best way to proceed w.r.t. the previous contributions?

Please let me know what would be best for you and I'll happily adjust :-)

@lattner
Copy link
Contributor

lattner commented Mar 11, 2016

Yes, please do. We need to keep the license consistent for all code in the swift project. Please change it to the standard header blob, or we'll have to remove it :-( Thank you!

…idateDecl(swift::ValueDecl*, bool)

Stack trace:

```
swift: /path/to/swift/lib/Sema/TypeCheckDecl.cpp:6379: void swift::TypeChecker::validateDecl(swift::ValueDecl *, bool): Assertion `gp->getOuterParameters() == proto->getDeclContext()->getGenericParamsOfContext()' failed.
8  swift           0x0000000000e417fe swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 7134
9  swift           0x000000000107b82c swift::DeclContext::lookupQualified(swift::Type, swift::DeclName, unsigned int, swift::LazyResolver*, llvm::SmallVectorImpl<swift::ValueDecl*>&) const + 3612
10 swift           0x0000000001079ef0 swift::UnqualifiedLookup::UnqualifiedLookup(swift::DeclName, swift::DeclContext*, swift::LazyResolver*, bool, swift::SourceLoc, bool, bool) + 2384
11 swift           0x0000000000e7f38b swift::TypeChecker::lookupUnqualified(swift::DeclContext*, swift::DeclName, swift::SourceLoc, swift::OptionSet<swift::NameLookupFlags, unsigned int>) + 187
14 swift           0x0000000000eaa10e swift::TypeChecker::resolveIdentifierType(swift::DeclContext*, swift::IdentTypeRepr*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, bool, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 158
16 swift           0x0000000000eab024 swift::TypeChecker::resolveType(swift::TypeRepr*, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 164
17 swift           0x0000000000eaa00a swift::TypeChecker::validateType(swift::TypeLoc&, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 42
18 swift           0x0000000000f623af swift::IterativeTypeChecker::processResolveInheritedClauseEntry(std::pair<llvm::PointerUnion<swift::TypeDecl*, swift::ExtensionDecl*>, unsigned int>, llvm::function_ref<bool (swift::TypeCheckRequest)>) + 159
19 swift           0x0000000000f40d3d swift::IterativeTypeChecker::satisfy(swift::TypeCheckRequest) + 493
20 swift           0x0000000000e3c9f9 swift::TypeChecker::resolveInheritanceClause(llvm::PointerUnion<swift::TypeDecl*, swift::ExtensionDecl*>) + 137
21 swift           0x0000000000e4015b swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 1339
22 swift           0x0000000000e3fcf1 swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 209
25 swift           0x0000000001073202 swift::namelookup::lookupInModule(swift::ModuleDecl*, llvm::ArrayRef<std::pair<swift::Identifier, swift::SourceLoc> >, swift::DeclName, llvm::SmallVectorImpl<swift::ValueDecl*>&, swift::NLKind, swift::namelookup::ResolutionKind, swift::LazyResolver*, swift::DeclContext const*, llvm::ArrayRef<std::pair<llvm::ArrayRef<std::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*> >) + 1122
26 swift           0x000000000107a52a swift::UnqualifiedLookup::UnqualifiedLookup(swift::DeclName, swift::DeclContext*, swift::LazyResolver*, bool, swift::SourceLoc, bool, bool) + 3978
27 swift           0x0000000000e7f38b swift::TypeChecker::lookupUnqualified(swift::DeclContext*, swift::DeclName, swift::SourceLoc, swift::OptionSet<swift::NameLookupFlags, unsigned int>) + 187
30 swift           0x0000000000e88c60 swift::TypeChecker::inferDefaultWitnesses(swift::ProtocolDecl*) + 288
31 swift           0x0000000000e69318 swift::finishTypeChecking(swift::SourceFile&) + 536
32 swift           0x0000000000cbb88a swift::CompilerInstance::performSema() + 3514
34 swift           0x000000000078ad8b frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2523
35 swift           0x0000000000785835 main + 2837
Stack dump:
0.	Program arguments: /path/to/swift/bin/swift -frontend -c -primary-file validation-test/compiler_crashers/28263-swift-typechecker-validatedecl.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -module-name main -o /tmp/28263-swift-typechecker-validatedecl-5db636.o
1.	While resolving type c at [validation-test/compiler_crashers/28263-swift-typechecker-validatedecl.swift:14:13 - line:14:13] RangeText="c"
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
```
@practicalswift
Copy link
Contributor Author

@tkremenek @lattner Pull request updated - looks good now? :-)

lattner added a commit that referenced this pull request Mar 12, 2016
…hecker-validatedecl

[swiftc] Add test case for crash triggered in swift::TypeChecker::validateDecl(…)
@lattner lattner merged commit 583ea34 into swiftlang:master Mar 12, 2016
@tkremenek
Copy link
Member

@practicalswift Thank you for doing this.

kateinoigakukun pushed a commit to kateinoigakukun/swift that referenced this pull request Sep 7, 2020
[WASM] Update assertion condition for keypath projector in 5.3 branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants