SwiftLint: Bus error

New Issue Checklist

Describe the bug

swiftlint lint exits with a bus error when run on my machine, similar to #2391. It happens to me reliably.

See some investigation in the comments below.

Complete output when running SwiftLint, including the stack trace and command used
$ git clone https://github.com/signalapp/Signal-iOS.git
# ...

$ cd Signal-iOS

$ swiftlint lint
# ...lints some files...
# zsh: bus error  swiftlint lint

This also happens with swiftlint lint --quiet and swiftlint lint --no-cache.

The example output is lengthy, but nondeterministic (as far as I can tell).

There isn’t an obvious stack trace. (EDIT: See below for a stack trace.)

Environment

  • SwiftLint version: 0.47.1
  • Installation method used: Homebrew
  • Paste your configuration file: public here
  • Are you using nested configurations? No
  • Which Xcode version are you using (check xcodebuild -version)? Xcode 13.4, Build version 13F17a

About this issue

Most upvoted comments

Here’s some additional info just to help with the possible investigation of the issue.

I was able to reproduce a similar crash with the same “bus error” message by running SwiftLint v 0.47.0 on an M1 Mac using SwiftPM (swift run swiftlint).

Here’s a minimal file that triggered the crash:

import SwiftUI

struct CrashSwiftLint: View {
    var body: some View {
        VStack {
            VStack {
                VStack {
                    VStack {
                        Text("test")
                            .padding()
                            .padding()
                            .padding()
                            .padding()
                            .padding()
                            .padding()
                            .padding()
                            .padding()
                    }
                }
            }
        }
    }
}

However, swift run swiftlint builds the binary in debug configuration.

When I run SwiftLint in release configuration using swift run -c release swiftlint, it no longer crashes.

Hope that helps.

You must run SwiftLint via Swift Package Manager using swift run for the error to occur.

As I previously said:

SwiftSyntax in debug builds has massive stack frames, leading to stack overflows. Those are optimized away in release builds and not an issue from what I’ve seen.

To avoid these stack overflows, please run SwiftLint compiled with -c release when using SwiftPM or with --config=release when using Bazel, or just use the prebuilt release binaries.