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-2876] Subscript on Array(someString.characters) Crashes Compiler with Assert #45470

Closed
swift-ci opened this issue Oct 6, 2016 · 0 comments
Assignees
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 type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Oct 6, 2016

Previous ID SR-2876
Radar rdar://problem/26845038
Original Reporter donald-pinckney (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash, TypeChecker
Assignee @rudkx
Priority Medium

md5: eb8ea627702694001057416b113f7f78

relates to:

  • SR-2635 Crash with Xcode 8 Swift compiler

Issue Description:

Subscripting the result of the initializer directly crashes the type checker. Putting the array into a constant and then subscripting that works fine. See this for clarity:

vagrant@vagrant-ubuntu-wily-64:~/Documents/Write-Up-4/problem2/Sources$ cat main.swift 
print(Array("asdf".characters)[0])
vagrant@vagrant-ubuntu-wily-64:~/Documents/Write-Up-4/problem2/Sources$ swiftc main.swift 
swift: /home/buildnode/jenkins/workspace/oss-swift-3.0-package-linux-ubuntu-15_10/swift/lib/Sema/ConstraintGraph.cpp:207: void swift::constraints::ConstraintGraphNode::addFixedBinding(swift::TypeVariableType *): Assertion `!adjacency.FixedBinding && "Already marked as a fixed binding?"' failed.
0  swift           0x0000000003342e68 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40
1  swift           0x0000000003341666 llvm::sys::RunSignalHandlers() + 54
2  swift           0x0000000003343996
3  libpthread.so.0 0x00007f3e37301d10
4  libc.so.6       0x00007f3e35c491c7 gsignal + 55
5  libc.so.6       0x00007f3e35c4ae2a abort + 362
6  libc.so.6       0x00007f3e35c420bd
7  libc.so.6       0x00007f3e35c42172
8  swift           0x0000000000ffdbb2
9  swift           0x0000000000f5647e swift::constraints::ConstraintSystem::assignFixedType(swift::TypeVariableType*, swift::Type, bool) + 366
10 swift           0x0000000000fbd11f swift::constraints::ConstraintSystem::matchTypes(swift::Type, swift::Type, swift::constraints::TypeMatchKind, unsigned int, swift::constraints::ConstraintLocatorBuilder) + 3183
11 swift           0x0000000000fc0e27 swift::constraints::ConstraintSystem::matchFunctionTypes(swift::FunctionType*, swift::FunctionType*, swift::constraints::TypeMatchKind, unsigned int, swift::constraints::ConstraintLocatorBuilder) + 631
12 swift           0x0000000000fc0030 swift::constraints::ConstraintSystem::matchTypes(swift::Type, swift::Type, swift::constraints::TypeMatchKind, unsigned int, swift::constraints::ConstraintLocatorBuilder) + 15232
13 swift           0x0000000000fc9206 swift::constraints::ConstraintSystem::simplifyConstraint(swift::constraints::Constraint const&) + 630
14 swift           0x0000000000f575d7 swift::constraints::ConstraintSystem::addConstraint(swift::constraints::Constraint*, bool, bool) + 23
15 swift           0x0000000000f5b716 swift::constraints::ConstraintSystem::resolveOverload(swift::constraints::ConstraintLocator*, swift::Type, swift::constraints::OverloadChoice) + 2230
16 swift           0x0000000000fc9328 swift::constraints::ConstraintSystem::simplifyConstraint(swift::constraints::Constraint const&) + 920
17 swift           0x0000000000fd1c7b swift::constraints::ConstraintSystem::solveSimplified(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 11211
18 swift           0x0000000000fcda73 swift::constraints::ConstraintSystem::solveRec(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 323
19 swift           0x0000000000fd1d8d swift::constraints::ConstraintSystem::solveSimplified(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 11485
20 swift           0x0000000000fcda73 swift::constraints::ConstraintSystem::solveRec(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 323
21 swift           0x0000000000fd1d8d swift::constraints::ConstraintSystem::solveSimplified(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 11485
22 swift           0x0000000000fcda73 swift::constraints::ConstraintSystem::solveRec(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 323
23 swift           0x0000000000fcd829 swift::constraints::ConstraintSystem::solve(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 73
24 swift           0x0000000000eb3688 swift::TypeChecker::solveForExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem&, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 808
25 swift           0x0000000000eb98dd swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 621
26 swift           0x0000000000f35cee
27 swift           0x0000000000f34fd6 swift::TypeChecker::typeCheckTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 134
28 swift           0x0000000000ef006d swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1133
29 swift           0x0000000000c7b2a9 swift::CompilerInstance::performSema() + 3289
30 swift           0x00000000007dadcf
31 swift           0x00000000007d9ea1 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2833
32 swift           0x00000000007a693b main + 2603
33 libc.so.6       0x00007f3e35c34ac0 __libc_start_main + 240
34 swift           0x00000000007a44b9 _start + 41
Stack dump:
0.  Program arguments: /home/vagrant/bin/swift-3.0-RELEASE-ubuntu15.10/usr/bin/swift -frontend -c -primary-file main.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -color-diagnostics -module-name main -o /tmp/main-6b6ef8.o 
1.  While type-checking expression at [main.swift:1:1 - line:1:34] RangeText="print(Array("asdf".characters)[0])"
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
vagrant@vagrant-ubuntu-wily-64:~/Documents/Write-Up-4/problem2/Sources$ cat main2.swift 
let a = Array("asdf".characters)
print(a[0])
vagrant@vagrant-ubuntu-wily-64:~/Documents/Write-Up-4/problem2/Sources$ swiftc main2.swift 
vagrant@vagrant-ubuntu-wily-64:~/Documents/Write-Up-4/problem2/Sources$ ./main2
a
vagrant@vagrant-ubuntu-wily-64:~/Documents/Write-Up-4/problem2/Sources$ 
@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants