Skip to content

crashes in CI when running scala-cli fmt --check #4199

@dontgitit

Description

@dontgitit

Version(s)
1.12.5, via https://github.com/VirtusLab/scala-cli-setup/releases/tag/v1.12.5
previously 1.9.1, via https://github.com/VirtusLab/scala-cli-setup/releases/tag/v1.9.1

Describe the bug
I have a simple GitHub Actions job that runs scalafmt (with an older version of scala-cli):

  scalafmt:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v5
      - uses: coursier/cache-action@bebeeb0e6f48ebad66d3783946588ecf43114433 # v6.4.8
      - name: scala-cli-setup-action
        uses: VirtusLab/scala-cli-setup@77834b5926f3eb70869d8009530c65585f7a039b # v1.9.1
      - name: scalafmtCheckAll
        run: scala-cli fmt --check

This would occasionally segfault:

Run scala-cli fmt --check
  scala-cli fmt --check
  shell: /usr/bin/bash -e {0}
  env:
    JAVA_HOME: /home/runner/.cache/coursier/arc/https/github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.16%252B8/OpenJDK17U-jdk_x64_linux_hotspot_17.0.16_8.tar.gz/jdk-17.0.16+8
    COURSIER_BIN_DIR: /home/runner/cs/bin
Looking for unformatted files...
Looking for unformatted files... [          ]
  out 0.0% 0, fmt 0.0% 0, in 0.0% 0 todo=283
ScalaNative: Unrecoverable NullPointerException in user thread
/home/runner/work/_temp/c1fb3d54-ead7-4b0d-8640-a5d2dc86d101.sh: line 1:  2194 Segmentation fault      (core dumped) scala-cli fmt --check
Error: Process completed with exit code 139.

I updated to the latest scala-cli:

        uses: VirtusLab/scala-cli-setup@14e5155ee896fcc200f66f92c9eb7a3dd9b58e0d # v1.12.5

and now seeing a new occasional failure (only once so far):

Run scala-cli fmt --check
  scala-cli fmt --check
  shell: /usr/bin/bash -e {0}
  env:
    JAVA_HOME: /home/runner/.cache/coursier/arc/https/github.com/adoptium/temurin17-binaries/releases/download/jdk-17.0.16%252B8/OpenJDK17U-jdk_x64_linux_hotspot_17.0.16_8.tar.gz/jdk-17.0.16+8
    COURSIER_BIN_DIR: /home/runner/cs/bin
Looking for unformatted files...
Looking for unformatted files... [          ]
  out 0.0% 0, fmt 0.0% 0, in 0.0% 0 todo=284
java.lang.ClassCastException: class scala.scalanative.unsafe.CFuncPtr1 cannot be cast to scala.scalanative.runtime.ByteArray
	at scala.scalanative.runtime.package$.throwClassCast(Unknown Source)
	at java.nio.file.Files$.$anonfun$readAllBytes$1(Unknown Source)
	at java.nio.file.Files$$$Lambda$10.apply(Unknown Source)
	at scala.scalanative.unsafe.Zone$.acquire(Unknown Source)
	at org.scalafmt.sysops.GranularPlatformAsyncOps$.$anonfun$readFileAsync$1(Unknown Source)
	at org.scalafmt.sysops.GranularPlatformAsyncOps$$$Lambda$1.apply(Unknown Source)
	at scala.concurrent.Future$$$Lambda$1.apply(Unknown Source)
	at scala.concurrent.impl.Promise$Transformation.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
	at scala.scalanative.runtime.NativeThread$.threadEntryPoint(Unknown Source)
	at <none>._SM49scala.scalanative.runtime.NativeThread$$$Lambda$1G17$extern$forwarder(Unknown Source)
	at <none>.(Unknown Source)
	at <none>.(Unknown Source)
	at <none>.(Unknown Source)
Looking for unformatted files... [          ]
  out 0.7% 2, fmt 0.7% 2, in 1.1% 3/1 todo=280
error: UnexpectedError=8
Error: Process completed with exit code 8.

To Reproduce
Unfortunately the code being formatted is a private repository (and the issue is infrequent). The segfault occurred roughly once in every 20-100 runs. Since updating to the latest scala-cli, I witnessed the ClassCastException just a single time (in a total of maybe 10 runs).

Expected behaviour
I expect scala-cli fmt --check to not crash

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfmtIssues tied to the fmt sub-command

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions