SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

illegal instruction: 4 swiftlint on Xcode 11

Open Igor-Palaguta opened this issue 7 years ago • 23 comments

New Issue Checklist

Describe the bug

On beta 2 everything worked fine, but on Xcode 11 beta 3 swiftlint starts failing with illegal instruction: 4 swiftlint

SwiftLint.build/Script-77CC59392189ADCC00127275.sh: line 9: 34044 Illegal instruction: 4  swiftlint

After commenting opt in rules one by one found that it was because of reduce_into and trailing_closure rules

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint
Linting 'AAAA.swift' (199/1121)
Linting 'AAAA.swift' (200/1121)
Linting 'AAAA.swift' (201/1121)
Linting 'AAAA.swift' (202/1121)
Linting 'AAAA.swift' (203/1121)
Illegal instruction: 4

After commenting:

  #- reduce_into
  #- trailing_closure
  • SwiftLint version (run swiftlint version to be sure)? 0.33.0
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? package attached to github release
  • Paste your configuration file:
opt_in_rules:
  - anyobject_protocol
  - array_init
  - attributes
  - closure_end_indentation
  - closure_spacing
  - collection_alignment
  - contains_over_first_not_nil
  - conditional_returns_on_newline
  - discouraged_object_literal
  - empty_count
  - empty_string
  - empty_xctest_method
  - explicit_init
  - fallthrough
  - fatal_error_message
  - file_header
  - first_where
  - force_unwrapping
  - identical_operands
  - implicit_return
  - joined_default_parameter
  - let_var_whitespace
  - literal_expression_end_indentation
  - legacy_random
  - lower_acl_than_parent
  - modifier_order
  - multiline_arguments
  - multiline_parameters
  - nimble_operator
  - number_separator
  - operator_usage_whitespace
  - overridden_super_call
  - private_action
  - private_outlet
  - prohibited_super_call
  - reduce_into
  - redundant_nil_coalescing
  - redundant_type_annotation
  - single_test_class
  - sorted_first_last
  - sorted_imports
  - static_operator
  - strict_fileprivate
  - strong_iboutlet
  - switch_case_on_newline
  - toggle_bool
  - trailing_closure
  - unavailable_function
  - unneeded_parentheses_in_closure_argument
  - unused_import
  - unused_private_declaration
  - vertical_parameter_alignment_on_call
  - yoda_condition
  • Are you using nested configurations? no If so, paste their relative paths and respective contents.
  • Which Xcode version are you using (check xcode-select -p)?
xcodebuild -version
Xcode 11.0
Build version 11M362v

Igor-Palaguta avatar Jul 04 '19 16:07 Igor-Palaguta

Screenshot 2019-07-04 at 18 36 31

Igor-Palaguta avatar Jul 04 '19 16:07 Igor-Palaguta

Can you provide a sample snippet that triggers the issue when linted?

marcelofabri avatar Jul 04 '19 16:07 marcelofabri

It fails in raw strings with properties inside interpolation.

import XCTest

final class Class: XCTestCase {
    func testA() {
        let data = Data(#"{"status":100, "code":\#(a.code), "message": "failure"}"#.utf8)
    }
}

Igor-Palaguta avatar Jul 04 '19 16:07 Igor-Palaguta

Thanks for sharing steps to reproduce! I have a fix in progress here: https://github.com/jpsim/SourceKitten/pull/602

jpsim avatar Jul 10 '19 21:07 jpsim

Actually, digging more into this, it's a bug in SourceKit in Xcode 11. Will report back when I've filed a bug at bugs.swift.org.

jpsim avatar Jul 10 '19 21:07 jpsim

Filed a bug against SourceKit: https://bugs.swift.org/browse/SR-11099

jpsim avatar Jul 10 '19 21:07 jpsim

Thank you!

Igor-Palaguta avatar Jul 10 '19 21:07 Igor-Palaguta

Same issue in new rule no_space_in_method_call in 0.35. Screenshot 2019-09-06 at 17 40 37

Igor-Palaguta avatar Sep 06 '19 15:09 Igor-Palaguta

Same issue with Xcode 11 Beta 7. Disabling no_space_in_method_call helps.

lgaches avatar Sep 09 '19 07:09 lgaches

Also, disabling reduce_into opt-in rule helps

Doxxer avatar Sep 09 '19 18:09 Doxxer

The following opt-in rules can also trigger this bug:

  • multiline_function_chains
  • trailing_closure
  • unused_declaration

Hope this gets fixed upstream soon 🤞🏻

guillaumealgis avatar Sep 12 '19 17:09 guillaumealgis

Looks like a fix was pushed to the Swift compiler (https://github.com/apple/swift/pull/26354), but it's unclear when it'll be on official toolchains.

marcelofabri avatar Sep 12 '19 17:09 marcelofabri

Xcode 11 GM with 0.34.0 works for me. But have the same issue with 0.35.0 😢 Will waiting for the new update .....

HevaWu avatar Sep 19 '19 06:09 HevaWu

I'm also hitting this issue on Xcode 11.1. Not sure what file it's happening on because if I lint just the last file it succeeds.

chrisballinger avatar Oct 21 '19 22:10 chrisballinger

In my case it was because of a file that ended with a #endif with no accompanying #if. I didn't see the compilation error because SwiftLint was failing before the compilation step in our build process.

chrisballinger avatar Oct 21 '19 22:10 chrisballinger

SwiftLint 0.34.0 (as opposed to the current 0.35.0) does seem to work fine with Xcode 11.1 so for anyone looking for a short-term workaround you can install 0.34.0 with Homebrew as follows:

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/6a748c632794a33350c415a4f330800095fdc730/Formula/swiftlint.rb

thuss avatar Oct 22 '19 16:10 thuss

It looks like the Swift fix landed in 5.1.1. Closing this.

jpsim avatar Nov 06 '19 18:11 jpsim

I'm still getting this with Swift 5.1.2 (Xcode 11.2) and SwiftLint 0.36.0.

This advice https://github.com/realm/SwiftLint/issues/2793#issuecomment-529342828 helps.

broadwaylamb avatar Nov 07 '19 19:11 broadwaylamb

@broadwaylamb thanks for sharing. Could you share steps to reproduce in a new issue please? Sounds like a different problem.

jpsim avatar Nov 07 '19 20:11 jpsim

@jpsim sure.

I'm using SwiftLint 0.36.0, macOS 10.15.1 with Xcode 11.2 and Swift 5.1.2.

git clone https://github.com/broadwaylamb/OpenCombine.git swiftlint-crash
cd swiftlint-crash
git checkout 806ea79d672c58ef53a79df1e01253332e7af5c6
swiftlint

After linting some files I get:

[1]    27084 illegal hardware instruction  swiftlint

broadwaylamb avatar Nov 08 '19 19:11 broadwaylamb