SwiftLint: Crash introduced in 0.26.0
New Issue Checklist
- Updated SwiftLint to the latest version
- I searched for existing GitHub issues
There is a similar issue (https://github.com/realm/SwiftLint/issues/2039) but the stack traces seem unrelated
Bug Report
Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint
Loading configuration from '.swiftlint.yml'
Linting Swift files in current working directory
Linting 'DarwinNotificationCenter.swift' (1/96)
Linting 'OAuth2Error.swift' (2/96)
Linting 'OAuth2TokenRefreshCoordinator.swift' (3/96)
Linting 'OAuth2TokenDiskStore.swift' (4/96)
...
Linting 'URLSessionClient.swift' (55/96)
Linting 'HTTPRequestBuilder.swift' (56/96)
[1] 53616 illegal hardware instruction swiftlint
Environment
-
SwiftLint version (run
swiftlint versionto be sure)? 0.26.0 -
Installation method used (Homebrew, CocoaPods, building from source, etc)? Homebrew
-
Paste your configuration file:
included:
- Sources
- Tests
excluded:
- Sources/Conduit/Auth/Vendor
line_length: 160
statement_position:
statement_mode: uncuddled_else
type_name:
min_length: 3
max_length: 60
identifier_name:
min_length: 3
max_length: 60
opt_in_rules:
- attributes
- closure_end_indentation
- closure_spacing
- conditional_returns_on_newline
- empty_count
- fatal_error_message
- first_where
- force_unwrapping
- joined_default_parameter
- let_var_whitespace
- nimble_operator
- no_extension_access_modifier
- number_separator
- object_literal
- operator_usage_whitespace
- overridden_super_call
- pattern_matching_keywords
- private_outlet
- prohibited_super_call
- quick_discouraged_call
- redundant_nil_coalescing
- single_test_class
- strict_fileprivate
- switch_case_on_newline
- trailing_closure
- unneeded_parentheses_in_closure_argument
- vertical_parameter_alignment_on_call
Note: This crash still occurs when running swiftlint --enable-all-rules
-
Are you using nested configurations? If so, paste their relative paths and respective contents. No
-
Which Xcode version are you using (check
xcode-select -p)? Xcode 9.4.1, active developer directory is set to/Applications/Xcode.app/Contents/Developer -
Do you have a sample that shows the issue? Not yet sure about the exact source of the crash, but this exact failure can be observed here: https://travis-ci.org/mindbody/Conduit
The issue specifically started happening once SwiftLint was updated from 0.25.1 to 0.26.0.
Crash log:
Process: swiftlint [53483]
Path: /usr/local/Cellar/swiftlint/0.26.0/bin/swiftlint
Identifier: swiftlint
Version: 0
Code Type: X86-64 (Native)
Parent Process: zsh [50825]
Responsible: swiftlint [53483]
User ID: 566097933
Date/Time: 2018-07-02 15:55:20.807 -0700
OS Version: Mac OS X 10.13.4 (17E202)
Report Version: 12
Anonymous UUID: 77753AA3-F9B6-66B2-C051-8544C46F5487
Sleep/Wake UUID: FB630A13-637E-437D-A2BE-DDCC8D1AF37B
Time Awake Since Boot: 170000 seconds
Time Since Wake: 25000 seconds
System Integrity Protection: enabled
Crashed Thread: 7 Dispatch queue: com.apple.root.user-initiated-qos
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Illegal instruction: 4
Termination Reason: Namespace SIGNAL, Code 0x4
Terminating Process: exc handler [0]
Thread 7 Crashed:: Dispatch queue: com.apple.root.user-initiated-qos
0 swiftlint 0x00000001052c4704 NSString.CacheContainer.location(fromByteOffset:) + 468
1 swiftlint 0x00000001052c3dcd NSString.byteRangeToNSRange(start:length:) + 109
2 swiftlint 0x000000010546603f specialized NoFallthroughOnlyRule.validate(file:kind:dictionary:) + 143
3 swiftlint 0x000000010536b251 _T018SwiftLintFramework7ASTRulePAASS8KindType_8RawValueRTzrlE8validateSayAA14StyleViolationVG012SourceKittenC04FileC4file_s10DictionaryVySSAK0L16KitRepresentable_pG10dictionarytFAjRcfU_Tf4gnn_nAA12ForWhereRuleV_Tg5Tm + 433
4 swiftlint 0x000000010536b2f7 _T018SwiftLintFramework7ASTRulePAASS8KindType_8RawValueRTzrlE8validateSayAA14StyleViolationVG012SourceKittenC04FileC4file_s10DictionaryVySSAK0L16KitRepresentable_pG10dictionarytFAjRcfU_Tf4gnn_nAA21NoFallthroughOnlyRuleV_Tg5 + 23
5 swiftlint 0x000000010536b167 _T018SwiftLintFramework7ASTRulePAASS8KindType_8RawValueRTzrlE8validateSayAA14StyleViolationVG012SourceKittenC04FileC4file_s10DictionaryVySSAK0L16KitRepresentable_pG10dictionarytFAjRcfU_Tf4gnn_nAA12ForWhereRuleV_Tg5Tm + 199
6 swiftlint 0x000000010536b2f7 _T018SwiftLintFramework7ASTRulePAASS8KindType_8RawValueRTzrlE8validateSayAA14StyleViolationVG012SourceKittenC04FileC4file_s10DictionaryVySSAK0L16KitRepresentable_pG10dictionarytFAjRcfU_Tf4gnn_nAA21NoFallthroughOnlyRuleV_Tg5 + 23
7 swiftlint 0x000000010536b167 _T018SwiftLintFramework7ASTRulePAASS8KindType_8RawValueRTzrlE8validateSayAA14StyleViolationVG012SourceKittenC04FileC4file_s10DictionaryVySSAK0L16KitRepresentable_pG10dictionarytFAjRcfU_Tf4gnn_nAA12ForWhereRuleV_Tg5Tm + 199
8 swiftlint 0x000000010536b2f7 _T018SwiftLintFramework7ASTRulePAASS8KindType_8RawValueRTzrlE8validateSayAA14StyleViolationVG012SourceKittenC04FileC4file_s10DictionaryVySSAK0L16KitRepresentable_pG10dictionarytFAjRcfU_Tf4gnn_nAA21NoFallthroughOnlyRuleV_Tg5 + 23
9 swiftlint 0x000000010536b167 _T018SwiftLintFramework7ASTRulePAASS8KindType_8RawValueRTzrlE8validateSayAA14StyleViolationVG012SourceKittenC04FileC4file_s10DictionaryVySSAK0L16KitRepresentable_pG10dictionarytFAjRcfU_Tf4gnn_nAA12ForWhereRuleV_Tg5Tm + 199
10 swiftlint 0x000000010536b2f7 _T018SwiftLintFramework7ASTRulePAASS8KindType_8RawValueRTzrlE8validateSayAA14StyleViolationVG012SourceKittenC04FileC4file_s10DictionaryVySSAK0L16KitRepresentable_pG10dictionarytFAjRcfU_Tf4gnn_nAA21NoFallthroughOnlyRuleV_Tg5 + 23
11 swiftlint 0x000000010536dcdb _T018SwiftLintFramework7ASTRulePAASS8KindType_8RawValueRTzrlE8validateSayAA14StyleViolationVG012SourceKittenC04FileC4file_tFTf4gn_nAA12ForWhereRuleV_Tg5Tm + 171
12 swiftlint 0x0000000105368536 protocol witness for Rule.validate(file:) in conformance NoFallthroughOnlyRule + 22
13 swiftlint 0x0000000105341522 specialized Rule.lint(file:regions:benchmark:superfluousDisableCommandRule:) + 626
14 swiftlint 0x0000000105348790 partial apply for closure #2 in Linter.getStyleViolations(benchmark:) + 128
15 swiftlint 0x0000000105348811 _T018SwiftLintFramework4Rule_pAA0B6Result33_5A5F37FCDEE0B4D78BAE05A90BA8A062LLVSgIegio_AaB_pAFIegir_TRTA + 33
16 swiftlint 0x00000001052e081d specialized closure #1 in closure #1 in Array.parallelMap<A>(transform:) + 93
17 swiftlint 0x00000001052e7ae9 partial apply for specialized + 25
18 swiftlint 0x0000000105609bf7 thunk for @callee_guaranteed (@unowned Int) -> () + 39
19 libdispatch.dylib 0x00007fff6f832221 _dispatch_client_callout2 + 8
20 libdispatch.dylib 0x00007fff6f835d71 _dispatch_apply_serial + 111
21 libdispatch.dylib 0x00007fff6f827e08 _dispatch_client_callout + 8
22 libdispatch.dylib 0x00007fff6f83e019 _dispatch_sync_function_invoke + 54
23 libdispatch.dylib 0x00007fff6f832070 dispatch_apply_f + 947
24 swiftlint 0x0000000105609b99 static DispatchQueue.concurrentPerform(iterations:execute:) + 217
25 swiftlint 0x00000001052e05c5 specialized closure #1 in Array.parallelMap<A>(transform:) + 197
26 swiftlint 0x00000001052e5c88 specialized Array.parallelFlatMap<A>(transform:) + 232
27 swiftlint 0x000000010533966d Linter.getStyleViolations(benchmark:) + 1485
28 swiftlint 0x000000010533907d _T018SwiftLintFramework6LinterV15styleViolationsSayAA14StyleViolationVGvg + 13
29 swiftlint 0x00000001055cdd85 specialized closure #1 in LintCommand.run(_:) + 69
30 swiftlint 0x00000001055d22fc partial apply for closure #1 in LintCommand.run(_:) + 60
31 swiftlint 0x00000001055e0ed8 partial apply for closure #2 in closure #2 in closure #2 in Configuration.visitLintableFiles(path:action:useSTDIN:quiet:useScriptInputFiles:forceExclude:cache:parallel:visitorBlock:) + 104
32 swiftlint 0x00000001055e1599 closure #2 in closure #2 in closure #2 in Configuration.visitLintableFiles(path:action:useSTDIN:quiet:useScriptInputFiles:forceExclude:cache:parallel:visitorBlock:)partial apply + 9
33 swiftlint 0x00000001055e0f01 partial apply for thunk for @callee_guaranteed () -> (@error @owned Error) + 17
34 swiftlint 0x00000001055e1569 thunk for @callee_guaranteed () -> (@error @owned Error)partial apply + 9
35 swiftlint 0x00000001055ea57a autoreleasepool<A>(invoking:) + 58
36 swiftlint 0x00000001055e12fe specialized closure #2 in closure #2 in Configuration.visitLintableFiles(path:action:useSTDIN:quiet:useScriptInputFiles:forceExclude:cache:parallel:visitorBlock:) + 670
37 swiftlint 0x00000001055e0c63 partial apply for closure #2 in closure #2 in Configuration.visitLintableFiles(path:action:useSTDIN:quiet:useScriptInputFiles:forceExclude:cache:parallel:visitorBlock:) + 67
38 swiftlint 0x00000001055d94de closure #4 in closure #2 in Configuration.visitLintableFiles(path:action:useSTDIN:quiet:useScriptInputFiles:forceExclude:cache:parallel:visitorBlock:) + 126
39 swiftlint 0x00000001055e0f45 partial apply for closure #4 in closure #2 in Configuration.visitLintableFiles(path:action:useSTDIN:quiet:useScriptInputFiles:forceExclude:cache:parallel:visitorBlock:) + 21
40 swiftlint 0x0000000105609bf7 thunk for @callee_guaranteed (@unowned Int) -> () + 39
41 libdispatch.dylib 0x00007fff6f832221 _dispatch_client_callout2 + 8
42 libdispatch.dylib 0x00007fff6f83215d _dispatch_apply_invoke + 159
43 libdispatch.dylib 0x00007fff6f827e08 _dispatch_client_callout + 8
44 libdispatch.dylib 0x00007fff6f829b7c _dispatch_root_queue_drain + 902
45 libdispatch.dylib 0x00007fff6f8297a5 _dispatch_worker_thread3 + 101
46 libsystem_pthread.dylib 0x00007fff6fb79169 _pthread_wqthread + 1387
47 libsystem_pthread.dylib 0x00007fff6fb78be9 start_wqthread + 13
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 17 (3 by maintainers)
Commits related to this issue
- (Bugfix)|SwiftLint crashes due to Swift bug As discussed in https://github.com/realm/SwiftLint/issues/2276, there is a SourceKit bug involving switch case annotations when string interpolation is inv... — committed to mindbody/Conduit by johnhammerlund 6 years ago
- (Bugfix)|SwiftLint crashes due to Swift bug (#97) As discussed in https://github.com/realm/SwiftLint/issues/2276, there is a SourceKit bug involving switch case annotations when string interpolation ... — committed to mindbody/Conduit by johnhammerlund 6 years ago
- Limit SwiftLint version to 0.25.1 due to issue #2276 https://github.com/realm/SwiftLint/issues/2276 — committed to m3g0byt3/Podo by m3g0byt3 6 years ago
Yes, you are right, @marcelofabri.
I did not think of it at first, but now I remember being confused by SourceKit reporting bizarre numbers around interpolation cases—and I was using it directly, not through SourceKitten.
@johnhammerlund, in the meantime disabling
no_fallthrough_onlyought to avoid triggering the crash.The problem seems to reside in the SourceKitten framework, ironically caused by a force-unwrap.
SwiftLint 0.26.0 resolves to SourceKitten 0.21.0. Checking the SourceKitten repo, seems like a crash related to Swift 4.2 was fixed on the 0.21.1 release.
SourceKitten 0.21.1 does not seem to be available for SwiftLint (yet), since Yams is locked to 0.20.0.
@jpsim is there an easy way to remove that dependency block to see if 0.21.1 solves this issue?
I was able to reproduce the problem with this example:
Weirdly, it doesn’t happen if I remove the string interpolation.
Also, it looks like the first
byteRangeToNSRangecall is the one causing the crash, but everything on the rule looks fine up to that point.Reproduced this bug with this code
disabling no_fallthrough_only rule helps to prevent this crash.
I noticed that removing spaces in return statements will not trigger the crash
return "\(some)два"PS: reproduced on SwiftLint v 0.28.2 and 0.27
I think this is the same issue as https://github.com/jpsim/SourceKitten/issues/444 which was reported on SourceKit as well: https://bugs.swift.org/browse/SR-6443