libgomp segfault - example usage java z3
Hi All,
I encountered a segfault when running the java interface for z3 and figured out the alpine libgomp.so is to blame. I was able to get it working by disabling openMP and GMP usage in my build and wanted to know what y’all think.
The original ticket I put to z3 is here: https://github.com/Z3Prover/z3/issues/1702
Steps to reproduce:
Use the following dockerfile to make a container:
<code>
FROM alpine:latest
MAINTAINER Matthew Ahrens
ENV ES_JAVA_OPTS="-Xms512m -Xmx512m"
RUN apk update
RUN apk add musl
RUN apk add gcc
RUN apk add g++
RUN apk add git
RUN apk add libstdc++
RUN apk add openjdk8 && apk add openjdk8-jre
RUN apk add tar
RUN apk add wget
RUN apk add build-base
RUN apk add cmake
RUN apk add python3
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN apk add paxctl
RUN paxctl -c /usr/lib/jvm/default-jvm/jre/bin/java && paxctl -m /usr/lib/jvm/default-jvm/jre/bin/java && paxctl -c /usr/lib/jvm/default-jvm/bin/java && paxctl -m /usr/lib/jvm/default-jvm/bin/java
RUN apk upgrade
RUN wget https://github.com/Z3Prover/z3/releases/download/z3-4.7.1/z3-4.7.1.tar.gz
RUN tar -xzf z3-4.7.1.tar.gz
RUN export JAVA_HOME=/usr/lib/jvm/default-jvm && export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH && cd z3rel && mkdir build && cd build && cmake -DUSE_OPENMP=TRUE -DUSE_LIB_GMP=TRUE -DBUILD_JAVA_BINDINGS=TRUE ../ && make && make install && cp com.microsoft.z3.jar /usr/lib
</code>
Then in the image you can build the following java program:
<code class="java">
import com.microsoft.z3.Context;
public class Test{
public static void main(String[] args){
Context c = new Context();
}
}
</code>
build and run with:
javac -cp "/usr/lib:com.microsoft.z3.jar:." Test.java
java -cp "/usr/lib:com.microsoft.z3.jar:." Test
And you should get the same error I get:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x000066614dc1d14d, pid=13471, tid=0x00006661d0049ae8
#
# JRE version: OpenJDK Runtime Environment (8.0_171-b11) (build 1.8.0_171-b11)
# Java VM: OpenJDK 64-Bit Server VM (25.171-b11 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea 3.8.0
# Distribution: Custom build (Wed Jun 13 18:00:32 UTC 2018)
# Problematic frame:
# C [libgomp.so.1+0x814d] omp_set_nested+0xf
#
# Core dump written. Default location: /root/z3-z3-4.6.0/build/core or core.13471
#
# An error report file with more information is saved as:
# /root/z3-z3-4.6.0/build/hs_err_pid13471.log
#
# If you would like to submit a bug report, please include
# instructions on how to reproduce the bug and visit:
# http://icedtea.classpath.org/bugzilla
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Segmentation fault (core dumped)
(from redmine: issue id 9048, created on 2018-06-29)