Repository navigation
Description
New Issue Checklist
- I've Updated SwiftLint to the latest version.
- I've searched for existing GitHub issues.
Bug Description
A fully statically linked binary named swiftlint-static that does not require
any dynamic libraries at runtime. Rules requiring SourceKit will be disabled and
reported to the console when running this binary.
https://github.com/realm/SwiftLint/releases/tag/0.61.0
I have tried this new binary for Linux hoping that we can simply run SwiftLint on plain ubuntu env on GitHub Actions.
It crashed with segmentation fault when linting some code. This seems to occur on both AMD64 and ARM64.
$ ./swiftlint-static
Linting Swift files in current working directory...
....
Linting 'xxxx.swift' (57/616)
Segmentation fault (core dumped)
To reproduce the issue, I did set up Linux environment with Swiftly. I managed to get minimum input file that can reproduce the crash on linting and some backtrace by building static linux sdk binary with 0.61.0 tag locally.
Environment (I used VMware Fusion with Ubuntu Desktop image on macOS so it's ARM env)
ainame@ainame-vm:~/repos/SwiftLint$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04.3 LTS
Release: 24.04
Codename: noble
ainame@ainame-vm:~/repos/SwiftLint$ swiftly list
Installed release toolchains
----------------------------
Swift 6.1.2 (in use) (default)
Installed snapshot toolchains
-----------------------------
ainame@ainame-vm:~/repos/SwiftLint$ swift --version
Swift version 6.1.2 (swift-6.1.2-RELEASE)
Target: aarch64-unknown-linux-gnu
ainame@ainame-vm:~/repos/SwiftLint$ swift sdk list
swift-6.1.2-RELEASE_static-linux-0.0.1
ainame@ainame-vm:~/repos/SwiftLint$ swift build --product swiftlint -Xswiftc -DSWIFTLINT_DISABLE_SOURCEKIT --swift-sdk aarch64-swift-linux-musl -Xswiftc -g
ainame@ainame-vm:~/repos/SwiftLint$ lldb ./.build/debug/swiftlint
(lldb) target create "./.build/debug/swiftlint"
Current executable set to '/home/ainame/repos/SwiftLint/.build/debug/swiftlint' (aarch64).
(lldb) run --no-cache -- ./Bug.swift
Process 26811 launched: '/home/ainame/repos/SwiftLint/.build/debug/swiftlint' (aarch64)
Linting Swift files at paths ./Bug.swift
Linting 'Bug.swift' (1/1)
Process 26811 stopped
* thread #7, name = 'swiftlint', stop reason = signal SIGSEGV: invalid permissions for mapped object (fault address: 0xfffff7d34dc8)
frame #0: 0x00000000032202f0 swiftlint`Keyword.init(text=SwiftSyntax.SyntaxText @ 0x0000fffff7d36dc8) at Keyword.swift:228
225 case wrt
226 case yield
227
-> 228 @_spi(RawSyntax) public init?(_ text: SyntaxText) {
229 switch text.count {
230 case 2:
231 switch text {
Full backtrace from lldb is here
https://gist.github.com/ainame/9a5851a2fd5dc32b0189d38b6bbe7c57
Bug.swift that I used above is this (redacted one from actual source code from our project but still make it crash).
import Foundation
import UIKit
class CustomTextField: UIView {
private lazy var stackView: UIStackView = {
let stack = UIStackView(
axis: .vertical,
alignment: .fill,
distribution: .fill,
spacing: .s,
subviews: [
UIStackView(
axis: .vertical,
alignment: .fill,
distribution: .fill,
subviews: []
),
]
)
return stack
}()
}This of course doesn't make SwiftLint crash on macOS nor Ubuntu with normal debug build binary.
Environment
- SwiftLint version 0.61.0 / swiftlint-static for ARM64/AMD64
- Xcode version N/A
- Installation method used from GitHub Release page
- Configuration file: The issue persists with no config file
Activity
ainame commentedon Oct 8, 2025
I'm assuming this is more like either SwiftSyntax or even Swift compiler's (Static Link SDK?) issue. But I haven't been able to reproduce the same error without SwiftLint code yet. Once I identify minimum reproducible code for the crash with only SwiftSyntax, I'll report this problem to more appropriate place.
SimplyDanny commentedon Oct 8, 2025
Would you please provide the configuration you are using?
ainame commentedon Oct 8, 2025
@SimplyDanny Thank you for the quick response.
I tried with no .swiftlint.yml in place and still reproduced the crash. So the configuration is only the default settings.
SimplyDanny commentedon Oct 8, 2025
The reason for the error in the backtrace might be missing debug info from the SDK according to
Not sure if this is the actual issue or a follow-up. Because I can, at the moment, not reproduce the issue on Ubuntu 24.04.
ainame commentedon Oct 9, 2025
It looks like those warnings are produced because debug info (DWARF?) was embed in Static Linux SDK and those file paths won't be available on end-user's environment. It just degrade backtrace quality.
And the error is just a default behaviour of LLDB on non-Darwin platform?
https://github.com/swiftlang/llvm-project/blob/ac93ccbb3cd9d9627b55ba69400adb6479f2c87a/lldb/include/lldb/Target/Platform.h#L455-L459
@SimplyDanny Did you test this with x86_64 or aarch64? I have only MacBook Pro so haven't tried proper debugging with x86_64 yet. (I just ran the original 0.61.0 binary on x86_64 server and saw crashes when running swiftlint-static against a whole project.)
Regarding other configuration, I have only minimum set up on my VM.
I got the desktop image here https://cdimage.ubuntu.com/noble/daily-live/current/
And having these at
~/.profileSimplyDanny commentedon Oct 9, 2025
I ran my tests on x86_64.
ainame commentedon Oct 9, 2025
Now I also ran swiftlint-static against
Bug.swiftI shared above on x86_64 and confirmed it didn't crash. I'll try to find out minimum reproducible input file on x86_64 as well 🙇SimplyDanny commentedon Oct 9, 2025
Also on arm64, I'm unable to see the crash. Perhaps, you could try to setup a repository with the failing example and builds on both x86_64 and arm64 GitHub Action runners?
ainame commentedon Oct 10, 2025
No luck on GitHub Actions so far https://github.com/ainame/swiftlint-static-test/blob/main/.github/workflows/ci.yml
One suspect is that unlike glibc, musl seems to use limited stack size by default. So that parser implementation like SwiftSyntax and SwiftLint using it may hit that limit.
https://wiki.musl-libc.org/functional-differences-from-glibc.html
This is again, just my Ubuntu VM env on aarch64, the last output
[0x0000fffff7d77000-0x0000fffff7d79000) ---seems to indicate that the process exhausted all the stack available (according to ChatGPT, sorry I'm not very familiar with lldb)I will continue making more complex input to reliably reproduce the issue
ainame commentedon Oct 10, 2025
Actually increasing stack-size from 128K to 8M fixed the crash on my VM env.
This doesn't explain why existing 0.61.0's swiftlint-static didn't crash on my GitHub Actions though.
ainame commentedon Oct 10, 2025
I managed to reproduce crashes on GitHub Actions with https://github.com/apple/swift-nio repo's source.
https://github.com/ainame/swiftlint-static-test/actions/runs/18416560762/job/52481488144
https://github.com/ainame/swiftlint-static-test/blob/main/.github/workflows/ci.yml
I think next step would be to try binaries built with a larger stack-size mentioned above and see if it can fix the crash on GitHub Actions.
ainame commentedon Oct 11, 2025
The default thread stack-size that matches Darwin's one (512 KiB) helped.
I created a PR for this 🙏
#6291
ci(ios): retry a crashed swiftformat instead of failing the promotion…