You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@auron.apache.org by "fightBoxing (via GitHub)" <gi...@apache.org> on 2026/10/18 08:31:44 UTC
[I] [Bug] Executor SIGSEGV in jemalloc during native runtime teardown (arena_dalloc_small) [auron]
fightBoxing opened a new issue, #2586:
URL: https://github.com/apache/auron/issues/2586
## Summary
Running TPC-DS (SF100, ORC tables) with Auron native execution enabled on Spark 3.5.8 / YARN, three queries (`q4`, `q11`, `q30`) reproducibly crash the executor with `SIGSEGV` inside jemalloc. The crashing frame is in the **free** path:
```
_rjem_je_arena_dalloc_small+0x5c
tcache_bin_flush_edatas_lookup.isra.22+0x1ba
```
The crash occurs immediately after `native execution finalized` is logged, while a native producer task is being torn down. Fast queries on the same tables do not crash. This looks like a **double free / invalid free during native runtime teardown**, not an OOM (exit code is 134/SIGABRT after the JVM's nested crash handler, not 137).
## Environment
| Item | Value |
|---|---|
| Auron | `9.0.0-SNAPSHOT`, commit `a8ae4c37a24e894d672b3965f8b6ea86096fc8df` |
| Build | `./auron-build.sh --skiptests true --release --sparkver 3.5 --scalaver 2.12`, Linux x86_64 |
| Spark | 3.5.8 (Scala 2.12) |
| JDK | 17.0.20 (TencentKona), `-Xmx20g` |
| Deploy | YARN client mode via Kyuubi engine, `spark.executor.cores=10`, `spark.executor.memoryOverhead=10G` |
| Storage | HDFS (HA), ORC tables |
| Config | `spark.auron.enabled=true`, `spark.sql.extensions=AuronSparkSessionExtension`, `spark.shuffle.manager=AuronShuffleManager`, `spark.memory.offHeap.enabled=false` |
## Reproduction
1. Load TPC-DS SF100 as ORC tables.
2. Run the 99 TPC-DS queries sequentially through the same engine (same session).
3. `q4`, `q11`, `q30` fail; the other 96 succeed.
The three failing queries are exactly the three with the longest runtime:
| query | wall time | result |
|---|---|---|
| q4 | 73 s | executor crash |
| q30 | 38 s | executor crash |
| q11 | 32 s | executor crash |
| q49 | 29 s | ok |
| q23 | 23 s | ok |
Overall distribution of the 99 queries: `median=3s, p90=16s, max=73s`.
## Observed behavior
JVM fatal error report (sanitized):
```
# SIGSEGV (0xb) at pc=0x00007f4e655622fc
# Problematic frame:
# C [libauron-<...>.tmp+0x2b362fc] _rjem_je_arena_dalloc_small+0x5c
# The crash happened outside the Java Virtual Machine in native code.
```
Symbolization of the faulting offset against the built `libauron.so`:
```
_rjem_je_arena_dalloc_small
emap_edata_lookup -> rtree_read -> rtree_leaf_elm_read -> atomic_load_p
```
i.e. the pointer being freed has **no valid jemalloc extent metadata**, which is the signature of freeing a pointer that was never allocated by jemalloc, or was already freed.
Relevant native log tail before the crash:
```
[WARN] [auron native task 12.3 in stage ...] A failover has occurred since the start of call #9 ...
[INFO] [auron::rt:195] (stage: ..., partition: 0, tid: ...) - stream exhausted, sending Ok(None) to signal completion
[INFO] [auron::rt:290] (stage: 0, partition: 0, tid: 0) - (partition=0) native execution finalizing
[INFO] [auron::rt:303] (stage: 0, partition: 0, tid: 0) - (partition=0) native execution finalized
<crash>
```
Task is retried 4 times (`spark.task.maxFailures`), and **every** retry crashes at the same point (core dumps at 9 s intervals), so it is deterministic, not a random flake.
Core dump inspection shows **only one thread actually faults**; the `thread XXX also had an error` lines in the JVM report are other threads parked in `os::infinite_sleep()` during error reporting.
## What we ruled out
- **Not HDFS HA noise.** Every executor container in the run logs `StandbyException` while resolving the credential provider at startup, including all 96 successful queries. Mid-scan `StandbyException` also appears in containers that did not crash.
- **Not native operator count.** `q5` produces 397 native operators and 46 broadcast exchanges and completes normally in 19 s; `q30` crashes with only 42 native operators.
- **Not a time window.** `q11` crashes at 15:33:17; the next query starts 6 s later and succeeds.
- **Not OOM.** Exit is 134 (SIGABRT after nested handling), and `-XX:OnOutOfMemoryError` never fires.
## Code analysis (hypothesis)
`NativeExecutionRuntime::finalize` closes the tokio runtime non-blocking and then the owning struct is dropped:
```rust
// native-engine/auron/src/rt.rs
pub fn finalize(self) {
...
self.is_finalizing.store(true, Ordering::Release);
drop(self.batch_receiver);
cancel_all_tasks(&self.exec_ctx.task_ctx()); // cancel all pending streams
self.join_handle.abort();
self.tokio_runtime.shutdown_background();
log::info!("(partition={partition}) native execution finalized");
}
```
```rust
// native-engine/auron/src/exec.rs
pub extern "system" fn Java_org_apache_auron_jni_JniBridge_finalizeNative(_, _, raw_ptr: i64) {
let runtime = unsafe { Box::from_raw(raw_ptr as usize as *mut NativeExecutionRuntime) };
runtime.finalize();
}
```
`shutdown_background()` returns **without waiting** for worker threads, and `NativeExecutionRuntime` has no `Drop` impl that would join them. The struct is then dropped, releasing `exec_ctx: Arc<ExecutionContext>` and `native_wrapper: GlobalRef`.
The dangerous interleaving is on the error path. The producer task calls back into Java to set the error:
```rust
// native-engine/auron/src/rt.rs (spawned producer task)
let join_handle = tokio_runtime.spawn(async move {
consume_stream.await.unwrap_or_else(|err| {
handle_unwinded_scope(|| {
...
set_error(&native_wrapper_cloned, &format!("task panics: {err}"), cause)?;
log::info!("task exited abnormally.");
Ok(())
})
});
});
```
and the Java side closes the runtime immediately after observing that error:
```java
// auron-core/.../AuronCallNativeWrapper.java
public boolean loadNextBatch(Consumer<VectorSchemaRoot> batchConsumer) {
checkError();
try { ... } finally { checkError(); }
close();
return false;
}
protected void checkError() {
Throwable throwable = error.getAndSet(null);
if (throwable != null) { close(); throw new RuntimeException(throwable); }
}
public synchronized void close() {
if (nativeRuntimePtr != 0) {
JniBridge.finalizeNative(nativeRuntimePtr);
nativeRuntimePtr = 0;
...
}
}
```
So the sequence can be:
```
tokio worker : stream error -> set_error() -> returns into the spawned task
JVM thread : checkError() -> close() -> finalizeNative()
-> finalize() -> shutdown_background() (returns immediately)
-> Box drop
tokio worker : still executing on its stack / future still owned by the Runtime
```
`is_finalizing` narrows this window but is only a flag poll, not a synchronization barrier, so it does not close it. The result would be a double drop of a small Rust allocation, matching the observed `arena_dalloc_small` fault.
Related: the code already acknowledges this class of bug:
```rust
// native-engine/auron/src/lib.rs
// Defensive handling: this path should not be reached in normal operation
// after the SendError fixes (is_finalizing flag, FFI_ArrowArray lifetime).
```
## Why only the long queries
Short queries finish normally: the producer streams to completion and `send(Ok(None))` returns before `finalize()`, so the runtime is idle at teardown. The three crashing queries were interrupted mid-scan (ORC reads in flight when the HDFS read failed), so `finalize()` runs while the producer is still active. Race probability therefore scales with in-flight work at teardown, which correlates with runtime, not with data volume as such.
## Related
- #1065 reported a similar jemalloc crash (`tcache_bin_flush_edatas_lookup`) on macOS and was closed as stale; the Linux teardown path here appears to be a distinct, still-open issue.
## Suggested direction
1. Make `finalize()` wait for the producer before dropping the runtime (join the `JoinHandle`/spawned task, or use `shutdown_timeout()` instead of `shutdown_background()`), and/or implement `Drop` for `NativeExecutionRuntime` that joins workers.
2. Do not allow Java-side `finalizeNative` to run until the native side has confirmed the producer has exited.
3. Longer term, consider making jemalloc optional / feature-gated so a corruption can surface as a normal allocator abort instead of taking down the executor process.
Happy to provide the full `hs_err_pid*.log`, container stderr, and a symbolized core backtrace if useful.
--
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: commits-unsubscribe@auron.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org