Skip to content

Segmentation fault on a specific machine when using a binary built with the static Linux SDK #77841

Open
@Cyberbeni

Description

@Cyberbeni

Description

I have 2 machines. An Intel J4105 based one running Ubuntu 20.04 which doesn't have this issue and a Ryzen 1700x based one running Nobara 40, which does have this issue.

The crash happens using the binary from the artifactbundle found here: https://github.com/nicklockwood/SwiftFormat/releases/tag/0.55.2

Workspace I'm using for testing: Cyberbeni/Wiring@4f79227

When I run swiftformat, I get a segmentation fault:

> ~/Downloads/swiftformat_linux .
Running SwiftFormat...
Reading config file at /home/cyberbeni/Developer/Wiring/.swiftformat
[1]    6165 segmentation fault (core dumped)  ~/Downloads/swiftformat_linux .

But when I run this program in verbose mode, I don't get a crash:

> ~/Downloads/swiftformat_linux --verbose .
Running SwiftFormat...
Reading config file at /home/cyberbeni/Developer/Wiring/.swiftformat
...
SwiftFormat completed in 0.16s.
0/31 files formatted.

Same behaviour when running the same binary with podman: ghcr.io/nicklockwood/swiftformat:0.55.2

I also don't get a crash when running the code in the linked workspace inside a podman container.

Also no crash when using the container of version 0.54.5, which was built without the static SDK on swift:focal and copied over to swift:focal-slim

Also no crash when building locally without the static SDK with the following command: swift build --product swiftformat --configuration release -Xlinker -s

cc nicklockwood/SwiftFormat#1930

Reproduction

See description.

Stack dump

> coredumpctl info 
           PID: 4738 (swiftformat_lin)
           UID: 1000 (cyberbeni)
           GID: 1001 (cyberbeni)
        Signal: 11 (SEGV)
     Timestamp: Tue 2024-11-26 14:58:19 CET (9min ago)
  Command Line: /home/cyberbeni/Downloads/swiftformat_linux .
    Executable: /home/cyberbeni/Downloads/swiftformat_linux
 Control Group: /user.slice/user-1000.slice/user@1000.service/app.slice/app-org.kde.konsole@27e0da96d4f6401bba8ab0766af41051.service
          Unit: user@1000.service
     User Unit: app-org.kde.konsole@27e0da96d4f6401bba8ab0766af41051.service
         Slice: user-1000.slice
     Owner UID: 1000 (cyberbeni)
       Boot ID: ca63284dfda64320ae40facc142760fe
    Machine ID: 02f7a45841774093b59a960034641923
      Hostname: nobara-pc
       Storage: /var/lib/systemd/coredump/core.swiftformat_lin.1000.ca63284dfda64320ae40facc142760fe.4738.1732629499000000.zst (present)
  Size on Disk: 12.9M
       Message: Process 4738 (swiftformat_lin) of user 1000 dumped core.
                
                Module /home/cyberbeni/Downloads/swiftformat_linux without build-id.
                Stack trace of thread 4743:
                #0  0x00000000017cd57c n/a (/home/cyberbeni/Downloads/swiftformat_linux + 0x15cd57c)
                ELF object binary architecture: AMD x86-64

From /var/lib/systemd/coredump:

coredump.zip

Expected behavior

Swift files are formatted inside the folder that is passed in as an argument.

Environment

FROM --platform=$BUILDPLATFORM swift:6.0.1 AS builder
WORKDIR /workspace
RUN swift sdk install \
	https://download.swift.org/swift-6.0.1-release/static-sdk/swift-6.0.1-RELEASE/swift-6.0.1-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz \
	--checksum d4f46ba40e11e697387468e18987ee622908bc350310d8af54eb5e17c2ff5481

Also tried with 6.0.2:

FROM --platform=$BUILDPLATFORM swift:6.0.2 AS build
WORKDIR /workspace
RUN swift sdk install \
	https://download.swift.org/swift-6.0.2-release/static-sdk/swift-6.0.2-RELEASE/swift-6.0.2-RELEASE_static-linux-0.0.1.artifactbundle.tar.gz \
	--checksum aa5515476a403797223fc2aad4ca0c3bf83995d5427fb297cab1d93c68cee075

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    LinuxPlatform: LinuxbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwaretriage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions