CPU profiling event seemingly does not work
Describe the bug
I wanted to do some basic profiling on my Scala3 GUI application that runs on the JVM. I ran the sample command from the documentation asprof -e cpu -d 10 -f benchmark.html <PID>. It attaches to the process but as soon as my application is refocused, it just terminates.
Expected vs. actual behavior
I expected to generate the profiling file but the application abruptly terminates.
Reproduction Steps
I start up my application using the mill build system. mill core.run
The app uses Java 9's process api to print the PID to stdout. ProcessHandle.current().pid()
I attach asprof to the process. asprof -e cpu -d 10 -f benchmark.html 12572
asprof logs:
[WARN] Install JVM debug symbols to improve profile accuracy
Profiling for 10 seconds
Process exitedmill logs:
284] core.run
PID: 12572
[W][16:32:02.231131] pw.conf | [ conf.c: 1209 pw_conf_load_conf_for_context()] setting config.name to client-rt.conf is deprecated, using client.conf
284/284, 1 FAILED] ./mill core.run 34s
284] [error] core.run Subprocess failedAdditional Information/Context
I experimented a bit but could not find out a lot on what is happening.
- I tested other profiling modes like
allocandnativemem. Those ran fine and generated the html file. - I tried building the app from source. The behavior was the same as with the prebuilt binaries.
- I tried creating an "über-jar" first using
mill core.assemblyand attach to that but that did not help either. - I also ran the profiler on a single file "helloworld" that finished successfully without exiting.
My app only has one foreign dependency which is libgdx. This is the build script:
package build
import mill.*
import scalalib.*
trait CommonModule extends ScalaModule:
def scalaVersion = "3.5.0"
def scalacOptions = Seq(
"-deprecation",
"-Wsafe-init",
"-Wshadow:all",
"-Wunused:imports,params,privates",
)
object config extends CommonModule
object errors extends CommonModule
object extras extends CommonModule:
def moduleDeps = Seq(config, errors)
object multimedia extends CommonModule:
def moduleDeps = Seq(errors, extras)
object core extends CommonModule:
val gdxVersion = "1.13.5"
def mvnDeps = Seq(
mvn"com.badlogicgames.gdx:gdx:$gdxVersion",
mvn"com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion",
)
def runMvnDeps = Seq(
mvn"com.badlogicgames.gdx:gdx-platform:$gdxVersion;classifier=natives-desktop"
)
def moduleDeps = Seq(multimedia)Async-profiler version
Latest stable 4.5
Environment details
OS: Artix Linux 6.18.38-4-lts CPU: x86_64 openjdk version "21.0.11" 2026-04-21 OpenJDK Runtime Environment (build 21.0.11+10) OpenJDK 64-Bit Server VM (build 21.0.11+10, mixed mode, sharing) Not running in container
Source: async-profiler/async-profiler