Skip to content
Stephen Crowley edited this page Apr 9, 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.

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 `which 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.

For example...

crow@creator15:~/a$ jhsdb jstack  --core core.22951 --exe `which java`
Attaching to core core.22951 from executable /usr/bin/java, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 19.0.2+7-44
Deadlock Detection:

No deadlocks found.

"main" #1 prio=5 tid=0x00007fbaf002cd70 nid=22953 runnable [0x00007fbaf4ffd000]
   java.lang.Thread.State: RUNNABLE
   JavaThread state: _thread_in_native
 - arb.arbJNI.arb_get_str(long, arb.Real, int, long) @bci=0 (Interpreted frame)
 - arb.arb.arb_get_str(arb.Real, int, long) @bci=7, line=973 (Interpreted frame)
 - arb.Real.toString(int, boolean) @bci=27, line=854 (Interpreted frame)
 - arb.Real.toString(int) @bci=6, line=847 (Interpreted frame)
 - arb.Real.toString() @bci=51, line=827 (Interpreted frame)
 - arb.Complex.toString() @bci=92, line=669 (Interpreted frame)
 - java.util.Formatter$FormatSpecifier.printString(java.util.Formatter, java.lang.Object, java.util.Locale) @bci=89, line=3147 (Compiled frame)
 - java.util.Formatter$FormatSpecifier.print(java.util.Formatter, java.lang.Object, java.util.Locale) @bci=176, line=3025 (Compiled frame)
 - java.util.Formatter.format(java.util.Locale, java.lang.String, java.lang.Object[]) @bci=205, line=2781 (Interpreted frame)
 - java.io.PrintStream.implFormat(java.lang.String, java.lang.Object[]) @bci=51, line=1366 (Interpreted frame)
 - java.io.PrintStream.format(java.lang.String, java.lang.Object[]) @bci=17, line=1345 (Interpreted frame)
 - arb.functions.complex.SFunctionTest.testS() @bci=62, line=15 (Interpreted frame)
 - java.lang.invoke.DirectMethodHandle$Holder.invokeStatic(java.lang.Object) @bci=9 (Interpreted frame)
 - java.lang.invoke.LambdaForm$MH+0x000000080102cc00.invoke(java.lang.Object, java.lang.Object) @bci=12 (Interpreted frame)
 - java.lang.invoke.Invokers$Holder.invokeExact_MT(java.lang.Object, java.lang.Object, java.lang.Object) @bci=19 (Interpreted frame)
 - jdk.internal.reflect.DirectMethodHandleAccessor.invokeImpl(java.lang.Object, java.lang.Object[]) @bci=41, line=154 (Interpreted frame)
 - jdk.internal.reflect.DirectMethodHandleAccessor.invoke(java.lang.Object, java.lang.Object[]) @bci=23, line=104 (Interpreted frame)
 - java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[]) @bci=102, line=578 (Interpreted frame)
 - junit.framework.TestCase.runTest() @bci=107, line=177 (Interpreted frame)
 - junit.framework.TestCase.runBare() @bci=7, line=142 (Interpreted frame)
 - junit.framework.TestResult$1.protect() @bci=4, line=122 (Interpreted frame)
 - junit.framework.TestResult.runProtected(junit.framework.Test, junit.framework.Protectable) @bci=1, line=142 (Interpreted frame)
 - junit.framework.TestResult.run(junit.framework.TestCase) @bci=18, line=125 (Interpreted frame)
 - junit.framework.TestCase.run(junit.framework.TestResult) @bci=2, line=130 (Interpreted frame)
 - junit.framework.TestSuite.runTest(junit.framework.Test, junit.framework.TestResult) @bci=2, line=241 (Interpreted frame)
 - junit.framework.TestSuite.run(junit.framework.TestResult) @bci=40, line=236 (Interpreted frame)
 - org.junit.internal.runners.JUnit38ClassRunner.run(org.junit.runner.notification.RunNotifier) @bci=22, line=90 (Interpreted frame)
 - org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(org.eclipse.jdt.internal.junit.runner.TestExecution) @bci=72, line=93 (Interpreted frame)
 - org.eclipse.jdt.internal.junit.runner.TestExecution.run(org.eclipse.jdt.internal.junit.runner.ITestReference[]) @bci=27, line=40 (Interpreted frame)
 - org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(java.lang.String[], java.lang.String, org.eclipse.jdt.internal.junit.runner.TestExecution) @bci=62, line=529 (Interpreted frame)
 - org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(org.eclipse.jdt.internal.junit.runner.TestExecution) @bci=10, line=756 (Interpreted frame)
 - org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run() @bci=70, line=452 (Interpreted frame)
 - org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(java.lang.String[]) @bci=14, line=210 (Interpreted frame)

Clone this wiki locally