Skip to content

The new binaries built with Static Linux SDK crashes #6287

@ainame

Description

@ainame

New Issue Checklist

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUnexpected and reproducible misbehavior.integrationIssues related to integration of SwiftLint into toolchains.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions