我正在开发一个Spring Boot Web应用程序,它使用SWI-Prolog的jpl接口从Java调用Prolog.在开发模式下,一切正常.
当我将其部署到Docker时,通过API对jpl的首次调用运行良好.当我尝试再次调用jpl时,JVM崩溃.
我使用LD_PRELOAD指向libswipl.so
SWI_HOME_DIR也被设置.
LD_LIBRARY_PATH设置为指向libjvm.so
我的控制器功能:
@PostMapping("/rules/testAPI/")
@Timed
public List<String> insertRule() {
String use_module_http = "use_module(library(http/http_open)).";
jpl.init();
Query q1 = new Query(use_module_http);
if (!q1.hasNext()) {
System.out.println("Failed to load HTTP Module");
} else {
System.out.println("Succeeded to load HTTP Module");
}
return null;
}
控制台输出
第一次通话
Succeeded to load HTTP Module
第二次通话
#
# A Fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f31705294b2, pid=16, tid=0x00007f30d2eee700
#
# JRE version: OpenJDK Runtime Environment (8.0_191-b12) (build 1.8.0_191-8u191-b12-2ubuntu0.18.04.1-b12)
# Java VM: OpenJDK 64-Bit Server VM (25.191-b12 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [libswipl.so+0xb34b2] PL_thread_attach_engine+0xe2
#
# Core dump written. Default location: //core or core.16
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
我将错误日志文件上传到pastebin中. click here
有没有人遇到过同样的问题?有解决办法吗?
请注意,我也使用oracle-java-8进行了检查,但是发生相同的错误.
更新:
@CapelliC答案无效.
解决方法:
我想我会尝试“使用”该术语.例如
Query q1 = new Query(use_module_http);
if (!q1.hasNext()) {
System.out.println("Failed to load HTTP Module");
} else {
System.out.println("Succeeded to load HTTP Module:"+q1.next().toString());
// remember q1.close() if there Could be multiple soultions
}
或更好
if ((new Query(use_module_http)).onesolution() == null) ...
还是更好
if ((new Query(use_module_http)).hasSolution() == false) ...
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。