llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Crashdump during SwiftLint Analyze

Open playmer opened this issue 1 year ago • 1 comments

Hey folks, I'm not too familiar with the ecosystem here, I mostly work on various developer tooling for the Outlook Mobile applications. Recently I was looking into automating our usage of SwiftLint Analyze and at some point we started crashing LLVM while running it. I'm assuming this would be the correct fork to report it to, given that this is happening in the context of Swift, but I can remake this issue upstream if need be.

Here's the crashlog that's requested in the error:

Correcting 'Session.swift' (250/10510)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
(decl_context: )Stack dump:
0.	While performing cached IDE inspection if possible
1.	While performing cached IDE inspection in decl context:
    ---
    0x692871968 Module name=OLMWatchPhoneShared
      0x692872608 FileUnit file="/Users/joshuafisher/repos/client-cocoa/app-ios/OLMFoundations/OLMWatchPhoneShared/Networking/Session.swift"
        0x491097258 ClassDecl name=Session
          0x51248b7a8 AbstractFunctionDecl name=transferOngoingComplicationInfo() : (Session) -> () -> ()
    ---
2.	While evaluating request IDEInspectionSecondPassRequest(source_file "/Users/joshuafisher/repos/client-cocoa/app-ios/OLMFoundations/OLMWatchPhoneShared/Networking/Session.swift", )
3.	While evaluating request TypeCheckASTNodeAtLocRequest(0x51248b7a8 AbstractFunctionDecl name=transferOngoingComplicationInfo() : (Session) -> () -> (), )
4.	While type-checking expression at [/Users/joshuafisher/repos/client-cocoa/app-ios/OLMFoundations/OLMWatchPhoneShared/Networking/Session.swift:405:9 - line:405:86] RangeText="logAssertFail("Can't encode complication info: \(error.localizedDescription)""
5.	While type-checking-target starting at /Users/joshuafisher/repos/client-cocoa/app-ios/OLMFoundations/OLMWatchPhoneShared/Networking/Session.swift:405:9

I'm happy to do what I can to get more information, but keep in mind that I haven't been able to reproduce this on a smaller scale, and this takes hours to run even on an M3 Max. (Please talk to the SourceKit/Swift folks, seems something started harshly penalizing parallel calls several years ago)

If I understood the ecosystem more I'd be willing to try to debug it, but as it is I hit a barrier in the bowels of SwiftLint/SourceKitten, my very limited understanding is it's doing some sort of IPC to communicate with SourceKit and SourceKit is the one crashing in LLVM? So presumably I'd need to build SourceKit and LLVM myself to be able to actually see the crash? Not sure if that's doable on my side.

playmer avatar Apr 24 '25 12:04 playmer

@playmer you’re absolutely in the right place; this fork of llvm-project is used by Swift, and SwiftLint Analyze depends on SourceKit, which in turn uses this compiler backend.

From the stack trace, it looks like the crash happens during type-checking of this line:

logAssertFail("Can't encode complication info: \(error.localizedDescription)")

Specifically at the call to localizedDescription inside a string interpolation. This might suggest an issue with string interpolation or error-handling logic being analyzed under SwiftLint’s analyze mode.

I'm currently exploring how this crash might be reproducible in isolation, possibly by mimicking a similar function declaration and logging pattern. If I’m able to reduce this to a minimal example, I’ll update here.

I need to know version of SwiftLint and Swift are you using and if this crash reproducible consistently on that file, or intermittent? of if using a custom toolchain.

Anubhavick avatar Jul 20 '25 08:07 Anubhavick