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-7954] SourceKit crashes with "Assertion `shouldCollectToken() && "Disabled"' failed." when "key.name" is negative integer string #50489

Closed
norio-nomura opened this issue Jun 10, 2018 · 5 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@norio-nomura
Copy link
Contributor

Previous ID SR-7954
Radar None
Original Reporter @norio-nomura
Type Bug
Status Resolved
Resolution Done
Environment

ubuntu 16.04
swift-4.2-DEVELOPMENT-SNAPSHOT-2018-06-08-a

Additional Detail from JIRA
Votes 0
Component/s Source Tooling
Labels Bug
Assignee @rintaro
Priority Medium

md5: 6cccc597b8df475ef5887d06184bf745

Issue Description:

Reproducing steps:

  1. docker run --privileged -it --rm norionomura/swift:swift-4.2-branch

  2. git clone https://github.com/jpsim/SourceKitten.git

  3. cd SourceKitten/

  4. swift build

  5. .build/debug/sourcekitten request --yaml '
    key.request: source.request.editor.open
    key.name: "-1"
    key.sourcetext: "let a = 1"
    '

logs:

$ docker run --privileged -it --rm norionomura/swift:swift-4.2-branch
root@e4a20490bb53:/# git clone https://github.com/jpsim/SourceKitten.git
Cloning into 'SourceKitten'...
remote: Counting objects: 10013, done.
remote: Compressing objects: 100% (148/148), done.
remote: Total 10013 (delta 117), reused 170 (delta 89), pack-reused 9772
Receiving objects: 100% (10013/10013), 7.66 MiB | 990.00 KiB/s, done.
Resolving deltas: 100% (6415/6415), done.
Checking connectivity... done.
root@e4a20490bb53:/# cd SourceKitten/
root@e4a20490bb53:/SourceKitten# swift build
Fetching https://github.com/norio-nomura/Clang_C.git
Fetching https://github.com/Quick/Quick.git
Fetching https://github.com/Carthage/Commandant.git
Fetching https://github.com/jpsim/Yams.git
Fetching https://github.com/antitypical/Result.git
Fetching https://github.com/norio-nomura/SourceKit.git
Fetching https://github.com/drmohundro/SWXMLHash.git
Fetching https://github.com/Quick/Nimble.git
Completed resolution in 8.87s
Cloning https://github.com/Quick/Nimble.git
Resolving https://github.com/Quick/Nimble.git at 7.1.1
Cloning https://github.com/norio-nomura/Clang_C.git
Resolving https://github.com/norio-nomura/Clang_C.git at 1.0.3
Cloning https://github.com/jpsim/Yams.git
Resolving https://github.com/jpsim/Yams.git at 1.0.0
Cloning https://github.com/Carthage/Commandant.git
Resolving https://github.com/Carthage/Commandant.git at 0.13.0
Cloning https://github.com/antitypical/Result.git
Resolving https://github.com/antitypical/Result.git at 3.2.4
Cloning https://github.com/drmohundro/SWXMLHash.git
Resolving https://github.com/drmohundro/SWXMLHash.git at 4.7.0
Cloning https://github.com/Quick/Quick.git
Resolving https://github.com/Quick/Quick.git at 1.3.0
Cloning https://github.com/norio-nomura/SourceKit.git
Resolving https://github.com/norio-nomura/SourceKit.git at 1.0.1
Compile CYaml src/writer.c
Compile Swift Module 'SWXMLHash' (3 sources)
/SourceKitten/.build/checkouts/SWXMLHash.git--8537495678296207061/Source/SWXMLHash.swift:430:33: warning: conditional cast from 'Error' to 'NSError' always succeeds
        if let err = parseError as? NSError {
                                ^
Compile Swift Module 'Result' (2 sources)
Compile CYaml src/scanner.c
Compile Swift Module 'Commandant' (9 sources)
Compile CYaml src/reader.c
Compile CYaml src/parser.c
Compile CYaml src/emitter.c
Compile CYaml src/api.c
Compile Swift Module 'Yams' (16 sources)
Compile Swift Module 'SourceKittenFramework' (37 sources)
Compile Swift Module 'sourcekitten' (11 sources)
Linking ./.build/x86_64-unknown-linux/debug/sourcekitten
root@e4a20490bb53:/SourceKitten# .build/debug/sourcekitten request --yaml '
key.request: source.request.editor.open
key.name: "-1"
key.sourcetext: "let a = 1"
'
Could not read contents of `
key.request: source.request.editor.open
key.name: "-1"
key.sourcetext: "let a = 1"
`
sourcekitten: /home/buildnode/jenkins/workspace/oss-swift-4.2-package-linux-ubuntu-16_04/swift/lib/AST/Module.cpp:1372: ArrayRef<swift::Token> swift::SourceFile::getAllTokens() const: Assertion `shouldCollectToken() && "Disabled"' failed.
Aborted
root@e4a20490bb53:/SourceKitten# 

SeeAlso: jpsim/SourceKitten#529

@jpsim
Copy link
Contributor

jpsim commented Jun 24, 2018

@akyrtzi is this something that SourceKitten is doing incorrectly, or an issue in SourceKit?

@akyrtzi
Copy link
Member

akyrtzi commented Jun 25, 2018

@rintaro I think was looking at something similar.

@rintaro
Copy link
Mannequin

rintaro mannequin commented Jun 25, 2018

This is definitely a SourceKit bug.
I've been looking for reproducer of this crash with non-empty key.name. Thank you!

@rintaro
Copy link
Mannequin

rintaro mannequin commented Jul 12, 2018

master: #17753
swift-4.2-branch: #17875

@jpsim
Copy link
Contributor

jpsim commented Jul 21, 2018

Thank you for fixing this!

@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.
Projects
None yet
Development

No branches or pull requests

3 participants