yaooqinn opened a new pull request, #13789:
URL: https://github.com/apache/gluten/pull/13789

   ## What changes are proposed in this pull request?
   
   Fixes #13788.
   
   With `spark.gluten.sql.columnar.libpath` pointing at `libvelox.so`, the 
Velox backend
   passes only that file to `System.load`:
   
   ```scala
   } else {
     // Path based load. Ignore all other loaderes.
     JniLibLoader.loadFromPath(libPath)
   }
   ```
   
   `libvelox.so` links against `libgluten.so`, so the dynamic linker maps it, 
but the JVM
   runs `JNI_OnLoad` only for a library given to `System.load`. Native methods 
still bind
   (symbol lookup searches dependencies), so nothing fails at load time. The 
core JNI
   globals set in `cpp/core/jni/JniWrapper.cc` `JNI_OnLoad` stay null, and the 
first call
   that uses one crashes the JVM:
   
   ```
   #  SIGSEGV (0xb) ...
   V  [libjvm.so+0x9d35dd]  jni_NewObjectV+0xbd
   C  [libgluten.so+...]  JNIEnv_::NewObject(_jclass*, _jmethodID*, ...)
   C  [libgluten.so+...]  
Java_org_apache_gluten_metrics_IteratorMetricsJniWrapper_nativeFetchMetrics
   ```
   
   This PR loads `spark.gluten.sql.columnar.libname` (`libgluten.so` by 
default) from the
   same directory first, then the configured library. That is the same order as 
the
   default bundled-library load. If `libpath` already names the core library, 
it is loaded
   once. If the core library is missing, initialization fails with a message 
that names
   both settings, instead of crashing later. The `libpath` doc text now says 
this.
   
   Alternative not taken: initialize the core JNI state from the Velox 
`JNI_OnLoad` as well.
   That needs an idempotent init shared by two libraries and changes the 
default path too.
   
   ## How was this patch tested?
   
   - `VeloxListenerApiTest`: 4 new cases for the load list (core first, core 
only once,
     relative path, missing core library). `tests="5" errors="0" failures="0"`.
   - End to end, Spark 4.1.1 local, a 2-stage aggregate over parquet with
     `libpath=<build>/releases/libvelox.so`: without this change the JVM exits 
134 with the
     SIGSEGV above; with it the query returns the correct result.
   - `AllGlutenConfiguration` / `AllVeloxConfiguration` golden check passes 
after
     regenerating `docs/Configuration.md`.
   
   ## Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Opus 5.5
   


-- 
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]

Reply via email to