Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault detected when running an infinite, compiled loop #6350

Closed
connglli opened this issue Apr 3, 2023 · 2 comments
Closed

Segfault detected when running an infinite, compiled loop #6350

connglli opened this issue Apr 3, 2023 · 2 comments
Assignees
Labels

Comments

@connglli
Copy link

connglli commented Apr 3, 2023

Describe the issue

When running the following test using Graal, Graal crashed with a segmentation fault.

import java.lang.ref.WeakReference;
import java.math.MathContext;

class T {
  int f() {
    int q = 43837, p;
    MathContext u = null;
    for (int w = 648; w < 9230; w += 1)
      try {
        p = u.getPrecision();
      } catch (Throwable x) {
      } finally {
      }
    WeakReference r = null;
    try {
      while (r.get() != null) {}
    } catch (Throwable x) {
    } finally {
    }
    return (int) (long) q;
  }

  public static void main(String[] g) {
    T t = new T();
    for (; ; ) t.f();
  }
}

Steps to reproduce the issue

  1. javac T.java
  2. java -XX:ThreadPriorityPolicy=1 -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCIProduct -XX:-UnlockExperimentalVMOptions -XX:-BackgroundCompilation -XX:-PrintCompilation --illegal-access=deny T

Describe GraalVM and your environment:

More details

From the log, it looks liky the crash occurs because of C1 (and OSR): J 41% c1 T.f()I. However, there isn't any crash observed if we directly run the test in HotSpot. The following is part of the crash:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f28e6da077c, pid=162531, tid=162532
#
# JRE version: OpenJDK Runtime Environment GraalVM CE 23.1.0-dev (17.0.7+4) (build 17.0.7+4-jvmci-23.0-b09)
# Java VM: OpenJDK 64-Bit Server VM GraalVM CE 23.1.0-dev (17.0.7+4-jvmci-23.0-b09, mixed mode, sharing, tiered, jvmci, jvmci compiler, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# J 41% c1 T.f()I (73 bytes) @ 0x00007f28e6da077c [0x00007f28e6da06c0+0x00000000000000bc]
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to /home/simon/Desktop/test-jitcomp/ax-eval/bugs2/19.graal/mutant/red/ttt/core.162531)
#
# If you would like to submit a bug report, please visit:
#   https://github.com/oracle/graal/issues
#

---------------  S U M M A R Y ------------

Command Line: -XX:ThreadPriorityPolicy=1 -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCIProduct -XX:-UnlockExperimentalVMOptions -XX:-BackgroundCompilation -XX:-PrintCompilation --illegal-access=deny T

Host: Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz, 8 cores, 31G, Ubuntu 20.04.5 LTS
Time: Mon Apr  3 19:35:06 2023 CST elapsed time: 0.698355 seconds (0d 0h 0m 0s)

---------------  T H R E A D  ---------------

Current thread (0x00007f28f8025920):  JavaThread "main" [_thread_in_Java, id=162532, stack(0x00007f28fc2d0000,0x00007f28fc3d1000)]

Stack: [0x00007f28fc2d0000,0x00007f28fc3d1000],  sp=0x00007f28fc3cf950,  free space=1022k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
J 41% c1 T.f()I (73 bytes) @ 0x00007f28e6da077c [0x00007f28e6da06c0+0x00000000000000bc]
j  T.main([Ljava/lang/String;)V+9
v  ~StubRoutines::call_stub
V  [libjvm.so+0x7fc1e5]  JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x315
V  [libjvm.so+0x8972cd]  jni_invoke_static(JNIEnv_*, JavaValue*, _jobject*, JNICallType, _jmethodID*, JNI_ArgumentPusher*, JavaThread*) [clone .constprop.1]+0x38d
V  [libjvm.so+0x89a10e]  jni_CallStaticVoidMethod+0x16e
C  [libjli.so+0x46ae]  JavaMain+0xcfe
C  [libjli.so+0x7d39]  ThreadJavaMain+0x9

See more in hs_err_pid162531.log.

@oubidar-Abderrahim
Copy link
Member

Hi, Thank you for reporting this, we'll take a look into this shortly

@oubidar-Abderrahim oubidar-Abderrahim self-assigned this Apr 7, 2023
@matneu
Copy link
Member

matneu commented Dec 18, 2023

This is an upstream bug in C1: https://bugs.openjdk.org/browse/JDK-8310126

@matneu matneu closed this as completed Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants