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-14607] Swift compiler crashes when using argument and parameter type with Objective-C generic class imported as member #56959

Open
swift-ci opened this issue May 7, 2021 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented May 7, 2021

Previous ID SR-14607
Radar rdar://problem/77673457
Original Reporter SvyatoslavScherbina (JIRA User)
Type Bug
Environment
$ swiftc -version
Apple Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1)
Target: x86_64-apple-darwin19.5.0
Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: b78a2a70aafd3d4a719258530575997d

Issue Description:

1.h:

#import <Foundation/Foundation.h>

@interface A : NSObject
@end;

NS_SWIFT_NAME(A.B)
@interface AB<T> : NSObject
@end;

void takeAB(AB<id>* ab);

1.swift:

let ab = A.B<AnyObject>()
takeAB(ab)

Swift compiler run as

swiftc 1.swift -import-objc-header 1.h

crashes:
->

Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file 1.swift -target x86_64-apple-darwin19.5.0 -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -color-diagnostics -target-sdk-version 10.15.6 -import-objc-header /var/folders/_c/4nxwq8z91h331tr5pq1b29vh0000gp/T/1-cb0c58.pch -module-name main -o /var/folders/_c/4nxwq8z91h331tr5pq1b29vh0000gp/T/1-f296db.o 
1.  Apple Swift version 5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1)
2.  While evaluating request TypeCheckSourceFileRequest(source_file "1.swift")
3.  While type-checking statement at [1.swift:2:1 - line:2:10] RangeText="takeAB(ab"
4.  While type-checking expression at [1.swift:2:1 - line:2:10] RangeText="takeAB(ab"
0  swift                    0x00000001136bb865 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x00000001136ba865 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x00000001136bbe1f SignalHandler(int) + 111
3  libsystem_platform.dylib 0x00007fff6f90a5fd _sigtramp + 29
4  libsystem_platform.dylib 0x00007ffee0a775a8 _sigtramp + 18446744071311904712
5  swift                    0x000000010ff4e26e swift::constraints::ConstraintSystem::matchTypes(swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 94
6  swift                    0x000000010ff55532 swift::constraints::ConstraintSystem::matchDeepEqualityTypes(swift::Type, swift::Type, swift::constraints::ConstraintLocatorBuilder) + 1330
7  swift                    0x000000010ff6270c swift::constraints::ConstraintSystem::simplifyRestrictedConstraint(swift::constraints::ConversionRestrictionKind, swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 2332
8  swift                    0x000000010ff51c80 swift::constraints::ConstraintSystem::matchTypes(swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 14960
9  swift                    0x000000010ff63f1e swift::constraints::ConstraintSystem::simplifyRestrictedConstraint(swift::constraints::ConversionRestrictionKind, swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 8494
10 swift                    0x000000010ff51c80 swift::constraints::ConstraintSystem::matchTypes(swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 14960
11 swift                    0x000000010ff76aa0 swift::constraints::ConstraintSystem::addConstraintImpl(swift::constraints::ConstraintKind, swift::Type, swift::Type, swift::constraints::ConstraintLocatorBuilder, bool) + 96
12 swift                    0x000000010ff4db42 swift::constraints::ConstraintSystem::addConstraint(swift::constraints::ConstraintKind, swift::Type, swift::Type, swift::constraints::ConstraintLocatorBuilder, bool) + 66
13 swift                    0x000000010ff4c7d7 swift::constraints::matchCallArguments(swift::constraints::ConstraintSystem&, swift::FunctionType*, llvm::ArrayRef<swift::AnyFunctionType::Param>, llvm::ArrayRef<swift::AnyFunctionType::Param>, swift::constraints::ConstraintKind, swift::constraints::ConstraintLocatorBuilder, llvm::Optional<swift::constraints::TrailingClosureMatching>) + 2583
14 swift                    0x000000010ff73352 swift::constraints::ConstraintSystem::simplifyApplicableFnConstraint(swift::Type, swift::Type, llvm::Optional<swift::constraints::TrailingClosureMatching>, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 2626
15 swift                    0x000000010ff4db42 swift::constraints::ConstraintSystem::addConstraint(swift::constraints::ConstraintKind, swift::Type, swift::Type, swift::constraints::ConstraintLocatorBuilder, bool) + 66
16 swift                    0x000000010ff393e5 (anonymous namespace)::ConstraintGenerator::visitApplyExpr(swift::ApplyExpr*) + 1525
17 swift                    0x000000010ff2b52e (anonymous namespace)::ConstraintWalker::walkToExprPost(swift::Expr*) + 462
18 swift                    0x000000010ff24d27 generateConstraintsFor(swift::constraints::ConstraintSystem&, swift::Expr*, swift::DeclContext*) + 535
19 swift                    0x000000010ff233f4 swift::constraints::ConstraintSystem::generateConstraints(swift::constraints::SolutionApplicationTarget&, swift::FreeTypeVariableBinding) + 452
20 swift                    0x000000010ff87c9e swift::constraints::ConstraintSystem::solve(swift::constraints::SolutionApplicationTarget&, swift::FreeTypeVariableBinding) + 1038
21 swift                    0x00000001100c59ef swift::TypeChecker::typeCheckExpression(swift::constraints::SolutionApplicationTarget&, bool&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 799
22 swift                    0x00000001100c5618 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 360
23 swift                    0x00000001101aac3b swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 9115
24 swift                    0x00000001101a647a bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 314
25 swift                    0x00000001101a6645 swift::TypeChecker::typeCheckTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 261
26 swift                    0x00000001101e3648 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 792
27 swift                    0x00000001101e64a9 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 953
28 swift                    0x00000001101e31a4 swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 164
29 swift                    0x000000010f35e3b7 swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 6439
30 swift                    0x000000010f21f2fd swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6845
31 swift                    0x000000010f1a3c07 main + 1255
32 libdyld.dylib            0x00007fff6f711cc9 start + 1
<unknown>:0: error: unable to execute command: Segmentation fault: 11
<unknown>:0: error: compile command failed due to signal 11 (use -v to see invocation)
@typesanitizer
Copy link

Triggers an assertion failure on main.

Assertion failed: ((bool)bound1->getParent() == (bool)bound2->getParent() && "Mismatched parents of bound generics"), function matchDeepEqualityTypes, file CSSimplify.cpp, line 2622.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.
Stack dump:                                                                                                          0.      Program arguments: /Users/varun/foss-swift/build/Ninja-ReleaseAssert/swift-macosx-x86_64/bin/swift-frontend -
frontend -c -primary-file tmp.swift -target x86_64-apple-darwin21.0.0 -enable-objc-interop -sdk /Library/Developer/CommandLineTools/SDKs/MacOSX12.0.sdk -color-diagnostics -enable-experimental-concurrency -target-sdk-version 12.0 -impo
rt-objc-header /var/folders/9t/dn6p4v392nb8c8cwxfyxc84c0000gn/T/tmp-895e10.pch -module-name tmp -o /var/folders/9t/dn
6p4v392nb8c8cwxfyxc84c0000gn/T/tmp-3f0ab9.o                                                                          1.      Swift version 5.5-dev (LLVM db18384d5088938, Swift c417464359da8b6)
2.      While evaluating request TypeCheckSourceFileRequest(source_file "tmp.swift")                                 3.      While type-checking statement at [tmp.swift:2:1 - line:2:10] RangeText="takeAB(ab"
4.      While type-checking expression at [tmp.swift:2:1 - line:2:10] RangeText="takeAB(ab"                          Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOL
IZER_PATH` to point to it):                                                                                          0  swift-frontend           0x000000010a9cb647 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-frontend           0x000000010a9ca558 llvm::sys::RunSignalHandlers() + 248                                  2  swift-frontend           0x000000010a9cbc86 SignalHandler(int) + 278
3  libsystem_platform.dylib 0x00007fff2033f4ad _sigtramp + 29                                                        4  libsystem_platform.dylib 0x00007fa4ed415030 _sigtramp + 18446743686307732384
5  libsystem_c.dylib        0x00007fff20279f10 abort + 123                                                           6  libsystem_c.dylib        0x00007fff202792e3 err + 0
7  swift-frontend           0x000000010add34b3 swift::constraints::ConstraintSystem::matchDeepEqualityTypes(swift::Type, swift::Type, swift::constraints::ConstraintLocatorBuilder) (.cold.8) + 35
8  swift-frontend           0x0000000106aaa106 swift::constraints::ConstraintSystem::matchDeepEqualityTypes(swift::Type, swift::Type, swift::constraints::ConstraintLocatorBuilder) + 3270
9  swift-frontend           0x0000000106ac315a swift::constraints::ConstraintSystem::simplifyRestrictedConstraintImpl(swift::constraints::ConversionRestrictionKind, swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::
OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 714 

@typesanitizer
Copy link

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants