Open mildm8nnered opened 1 year ago
Actually, digging a little deeper, I'm not seeing the same stack as above, but instead what looks like a stack overflow:
#0 0x0000000100693500 in Lexer.Cursor.StateStack.currentState.getter [inlined] at /Users/martin.redington/Library/Developer/Xcode/DerivedData/SwiftLint-gklsqxiezwwcpadjrqtcoqyssyxg/SourcePackages/checkouts/swift-syntax/Sources/SwiftParser/Lexer/Cursor.swift:156
#1 0x00000001006934e0 in Lexer.Cursor.currentState.getter [inlined] at /Users/martin.redington/Library/Developer/Xcode/DerivedData/SwiftLint-gklsqxiezwwcpadjrqtcoqyssyxg/SourcePackages/checkouts/swift-syntax/Sources/SwiftParser/Lexer/Cursor.swift:231
#2 0x00000001006934d0 in Lexer.Cursor.nextToken(sourceBufferStart:stateAllocator:) at /Users/martin.redington/Library/Developer/Xcode/DerivedData/SwiftLint-gklsqxiezwwcpadjrqtcoqyssyxg/SourcePackages/checkouts/swift-syntax/Sources/SwiftParser/Lexer/Cursor.swift:309
#3 0x0000000100648db4 in $defer #1 () in Lexer.LexemeSequence.advance() [inlined] at /Users/martin.redington/Library/Developer/Xcode/DerivedData/SwiftLint-gklsqxiezwwcpadjrqtcoqyssyxg/SourcePackages/checkouts/swift-syntax/Sources/SwiftParser/Lexer/LexemeSequence.swift:58
...
#1815 0x0000000100027ac0 in specialized closure #1 in Configuration.visit(linters:visitor:duplicateFileNames:) at /Users/martin.redington/Documents/Hudl/Source/SwiftLint/Source/swiftlint/Extensions/Configuration+CommandLine.swift:201
#1816 0x0000000100022b24 in closure #1 in Configuration.visit(linters:visitor:duplicateFileNames:) ()
#1817 0x00000001000272a0 in partial apply for closure #1 in Configuration.visit(linters:visitor:duplicateFileNames:) ()
...
#1822 0x0000000100b73e34 in thunk for @escaping @callee_guaranteed @Sendable @async () -> (@out τ_0_0) ()
#1823 0x0000000100b73e18 in partial apply for thunk for @escaping @callee_guaranteed @Sendable @async () -> (@out τ_0_0) ()
But when I run the same code manually, in a unit test, it does not crash for me.
import SwiftParser
import SwiftSyntax
final class ParserTests: XCTestCase {
public func testXXX(){
let string = "// This source file is part of the Swift.org open source project\n// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors\n// Licensed under Apache License v2.0 with Runtime Library Exception\n//\n// See https://swift.org/LICENSE.txt for license information\n// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors\n\n// RUN: not %target-swift-frontend %s -emit-ir\n[{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{\n{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{func b(UInt=1 + 1 as?Int){{{{{ }struct c=1 + 1 + 1 as?Int){{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{\n[.==A{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{\n"
_ = Parser.parse(source: string)
}
}
You have to be careful. The Swift repository contains test cases that don't describe valid Swift code or are just very pathologic edge cases. SwiftLint doesn't guarantee anything if the code to be linted isn't valid. test/Parse/structure_overflow.swift
is such an example.
New Issue Checklist
Describe the bug
The following files are affected:
This may be a problem with SourceKit/SourceKitten:
Complete output when running SwiftLint, including the stack trace and command used
See above
Environment
swiftlint version
to be sure)?0.50.3
none
xcodebuild -version
)?See above for sample files that cause the issue