apache / apache/arrow-java

JVM failed when use gandiva udf with dynamic libraries

未關閉
#326 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
Type: bug
主要語言
Java
星號
94
分支
152
平均合併
3 天 16 小時
30 天內合併 PR
11

描述

Hi there,

Recently I'm trying to add some UDF with dynamic link libaries. It is fine compiling and running test in cpp, but when I call the udf from java, JVM failed with errors.

Steps to reproduce the issue
1 Prepare dynamic library 'libmytest.so'
```java

// code placeholder
#ifndef MYTEST_H
#define MYTEST_H
#ifdef __cplusplus
extern "C"{
#endif
float testSim();
#ifdef __cplusplus
}
#endif
#endif
```
2 Add simple code for the udf in file 'string_ops.cc'

 
```java

// code placeholder
FORCE_INLINEFORCE_INLINE
gdv_float32 test_sim_binary_binary(gdv_int64 context, const char* left, gdv_int32 left_len, const char* right,                 gdv_int32 right_len) {
float sim = testSim();
return sim;
}
```
 

3 Add function details in the function registry file 'function_registry_string.cc'
```java

// code placeholder
NativeFunction("test_sim", {}, DataTypeVector{binary(),binary()},float32(),
kResultNullIfNull, "sim_binary_binary", NativeFunction::kNeedsContext | NativeFunction::kCanReturnErrors)
```
4 Create test functions

5 Add link to the CMakeLists.txt

5 compile and test

6 write a java demo to call the udf

[hs_err_pid28288.log](hs_err_pid28288.log)

**Environment**: OS:Centos7.4
llvm:7.0.1
jdk:1.8.0_162
arrow:1.0.0
**Reporter**: [Leo89](https://issues.apache.org/jira/browse/ARROW-9624)
#### Original Issue Attachments:
- [hs_err_pid28288.log](https://issues.apache.org/jira/secure/attachment/13008955/hs_err_pid28288.log)

**Note**: *This issue was originally created as [ARROW-9624](https://issues.apache.org/jira/browse/ARROW-9624). Please see the [migration documentation](https://github.com/apache/arrow/issues/14542) for further details.*

貢獻指南

開啟貢獻指南

研究方向

首先查看 hs_err_pid28288.log,並使用 libmytest.so 重現對 Gandiva UDF 的 Java 呼叫。追蹤 string_ops.cc、function_registry_string.cc 和 CMakeLists.txt 中的 native UDF 變更,並比較 C++ 和 Java 路徑。完成的標準是 Java demo 不再導致 JVM 故障,同時動態函式庫 UDF 仍可呼叫。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
cpp, java
領域
backend
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
30/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。