OpenJDK在OpenHarmony上异常问题分析

0.前言

基于OpenHarmony的2022.06.30 master之前版本OpenJDK测试OK,但是之后版本测试报异常错误。

1.问题日志打印

图片.png

2.报错日志代码分析

src/java.base/unix/native/libjli/java_md_common.c

jclass
FindBootStrapClass(JNIEnv *env, const char* classname)
{
   if (findBootClass == NULL) {
       findBootClass = (FindClassFromBootLoader_t *)dlsym(RTLD_DEFAULT,
          "JVM_FindClassFromBootLoader");
       if (findBootClass == NULL) {
           JLI_ReportErrorMessage(DLL_ERROR4,
               "JVM_FindClassFromBootLoader");
           return NULL;
       }
   }
   return findBootClass(env, classname);
}

问题分析:
dlsym(RTLD_DEFAULT, “JVM_FindClassFromBootLoader”); 返回了NULL,导致异常;基于dlsym的RTLD_DEFAULT有问题;OpenHarmony中没有dlsym的RTLD_DEFAULT的使用,但是OpenJDK中有大量的使用;
图片.png

dlsym(RTLD_DEFAULT, name);
也就是说,handle=RTLD_DEFAULT,在网上查了下,这种情况下会发生的事情是,会在当前进程中按照 default library search order搜索name这个symbol,网上的介绍摘录如下:
http://www.qnx.de/developers/docs/6.4.0/neutrino/lib_ref/d/dlsym.html?lang=cn
If handle is a handle returned by dlopen(), you must not have closed that shared object by calling dlclose(). The dlsym() functions also searches for the named symbol in the objects loaded as part of the dependencies for that object.
If handle is RTLD_DEFAULT, dlsym() searches all objects in the current process, in load-order.
In the case of RTLD_DEFAULT, if the objects being searched were loaded with dlopen(), dlsym() searches the object only if the caller is part of the same dependency hierarchy, or if the object was loaded with global search access (using the RTLD_GLOBAL mode).

3.问题解决方案

社区修改了musl的libc的导致,提问题给社区:
https://gitee.com/openharmony/third_party_musl/issues/I5FJ0O
社区在musl中解决方案:
https://gitee.com/openharmony/third_party_musl/pulls/371
图片.png

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

民之码农

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值