Gradle 7 file watching in Alpine Docker container leads to JVM crash SIGSEGV

Running Gradle 7 inside an Alpine Docker container (e.g. python:3-alpine) crashes the JVM with a SIGSEGV in libnative-platform-file-events.so when file watching is enabled. The crash happens during task execution right after the automatic Gradle update. File watching was introduced in Gradle 7 and the crash is specific to Alpine Linux containers, which use musl libc.

This was a Gradle bug in the native file-watching integration on Alpine (musl). It was fixed by PR #17055, which shipped in Gradle 7.0.1, upgrade to 7.0.1 or later to resolve the crash. If you are stuck on 7.0.0, you can work around it by disabling file watching with the --no-watch-fs flag or org.gradle.vfs.watch=false in gradle.properties until you can upgrade.

Source: https://github.com/gradle/gradle/issues/16787

Source: https://github.com/gradle/gradle/issues/16787