Skip to content
Stephen Crowley edited this page Mar 31, 2023 · 18 revisions

The arb.Real class is an implementation of arbitrary-precision real valued numbers with ball arithmetic based on a modpoint-radius representation and automatic numerical accuracy tracking.

The number is stored in a memory region which can be prevented from being modified by invoking the lock() method which can be undone by calling the unlock() method.

For locking and unlocking to work, the Real must be allocated with the newAlignedVector(int) method because mprotect requires that the memory be aligned on a page boundary of the machines memory architecture.

If code tries to modify the locked buffer it will generate a segmentation fault which you can then debug to determine the source of the problem.

Catching Signals and Printing Stack Trace in JDK 19

import jdk.internal.misc.Signal;
import jdk.internal.misc.Signal.Handler;

public class CustomSignalHandler {
    public static void main(String[] args) {
        Signal.handle(new Signal("SEGV"), new Handler() {
            public void handle(Signal sig) {
                Thread.currentThread().getThreadGroup().list();
                System.exit(1);
            }
        });

        // Your JNI code and application logic here
    }
}


## Debugging JVM Crashes in JDK 19

1. **jhsdb:**
    - To get a stack trace from a running JVM:
      ```
      jhsdb jstack --pid <pid>
      ```
    - To analyze a core file generated by a crashed JVM:
      ```
      jhsdb hsdb --core <path_to_core_file> --exe java
      ```

2. **Thread.dumpStack():**
    - Use `Thread.dumpStack()` to print the current stack trace to the standard error output.

3. **Generate core dumps using external tools:**
    - Configure your OS to generate core dumps on crashes and set the core file size limit to "unlimited":
      ```
      ulimit -c unlimited
      ```
    - Use `jhsdb` to analyze the generated core dump, as described in option 1.


Clone this wiki locally