philo-he opened a new issue, #13729: URL: https://github.com/apache/gluten/issues/13729
### Backend VL (Velox) ### Bug description Executors crash with SIGSEGV when something walks the JVM thread list (e.g. a thread dump): ``` # Problematic frame: # C [libc.so.6+0x8c924] pthread_getcpuclockid+0x4 V [libjvm.so] Thread::print_on(outputStream*, bool) const VM_Operation: PrintThreads, requested by "Attach Listener" ``` Affects main, 1.7.0 and 1.8.0-rc1. ### Cause Native threads that Gluten attaches to the JVM are never detached. When one exits, the JVM keeps a `JavaThread` for a pthread that no longer exists, and the next thread-list walk dereferences it. #11896 (GLUTEN-11895) stopped calling `DetachCurrentThread` in the JNI helpers, because detaching breaks libhdfs's cached `JNIEnv*`, and added `JniAwareThreadFactory` to detach spill-pool threads instead. #11882, merged after it, moved the pools into `VeloxBackend` and removed `JniAwareThreadFactory` along with its only use. Since then no Gluten-attached thread is detached. The global IO, spill and broadcast-build (#13115) pools retire idle workers after `--threadtimeout_ms` (60 s), and their workers attach lazily (e.g. via `SparkAllocationListener`), so attached threads exit regularly. ### How it surfaced Found while benchmarking 1.8.0-rc1 with TPC-H/TPC-DS SF3000, Parquet on S3. 11 executors crashed in TPC-H and 20 in TPC-DS, all with the stack above. Each crash happened while an external process had attached to the executor JVM and requested a thread dump (`PrintThreads` from the `Attach Listener` thread); on our side, the node's log collection is one such process. `-XX:+DisableAttachMechanism` avoids this trigger but leaves the dangling threads in place. ### Conditions 1. Threads attached only by Gluten: S3/local scans, spill and broadcast-build pools. On HDFS scans, libhdfs detaches IO threads itself, which hides the bug. 2. Those threads exit: the executor idles for more than `--threadtimeout_ms` (60 s). 3. Something walks the JVM thread list: `jstack`, `jcmd Thread.print`, JVMTI agents, profilers, log collectors. 4. For a SIGSEGV, the dead thread's stack must be unmapped; `GLIBC_TUNABLES=glibc.pthread.stack_cache_size=0` makes this likely. ### Reproduce In local-mode `spark-shell` with Gluten, run some TPC-H queries, wait more than 60 s, run them again, then `jcmd <pid> Thread.print`. - Expected: every natively attached `"Thread-N"` entry (no Java frames) belongs to a live thread. - Actual: some of these entries have a `nid` that no longer exists under `/proc/<pid>/task/` (3 in our run). Repeated thread dumps eventually crash the JVM as above. ### Gluten version main branch ### Spark version None ### Spark configurations _No response_ ### System information _No response_ ### Relevant logs ```bash ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
