octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #53733] Panic/segfault when calling Java metho


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #53733] Panic/segfault when calling Java method after forge:im[read|write]
Date: Tue, 24 Apr 2018 17:14:43 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0

Follow-up Comment #12, bug #53733 (project octave):

It crashes for you inside the dlopen call?  That's weird.  For me, it crashes
inside the call to the create vm function.

This problem appears to be independent of Octave.

Try the following program:


#include <jni.h>
#include <stdlib.h>

int
main (void)
{
  JavaVMInitArgs vmArgs = { 0 };

  vmArgs.version = JNI_VERSION_1_8;
  vmArgs.nOptions = 0;
  vmArgs.ignoreUnrecognized = false;

  JNIEnv *env = NULL;
  JavaVM *jvm = NULL;

  jint ret = JNI_CreateJavaVM (&jvm, (void **) &env, &vmArgs);
  if (ret < 0 || jvm == NULL)
    {
      printf ("failed\n");
      //log(0, "Unable to create a Java Virtual Machine");
      return -1;
    }

  printf ("VM = %p\n", jvm);

  return 0;
}


Note that this doesn't use dlopen/dlsym.  On my system, I compile with


g++ -ggdb3 -I/usr/lib/jvm/java-9-openjdk-amd64/include
-I/usr/lib/jvm/java-9-openjdk-amd64/include/linux java-example.c
-L/usr/lib/jvm/java-9-openjdk-amd64/lib/server -ljvm


Your include file and library directories may be different.

Then if I run it with


$ LD_LIBRARY_PATH=/usr/lib/jvm/java-9-openjdk-amd64/lib/server ./a.out
VM = 0x7f2c09809d40


it appears to succeed and prints the address of the JVM object created by
JNI_CreateJavaVM.

However, if I run it with gdb, it segfaults in the same way as I am seeing
with Octave:


$ LD_LIBRARY_PATH=/usr/lib/jvm/java-9-openjdk-amd64/lib/server gdb ./a.out
GNU gdb (Debian 7.12-6+b1) 7.12.0.20161007-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./a.out...done.
(gdb) r
Starting program: /home/jwe/code-snippets/2/a.out 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00007fffdc00c4f3 in ?? ()
(gdb) where
#0  0x00007fffdc00c4f3 in ?? ()
#1  0x0000000000000206 in ?? ()
#2  0x00007fffdc00c280 in ?? ()
#3  0x00007ffff7d8df24 in Abstract_VM_Version::_vm_major_version () from
/usr/lib/jvm/java-9-openjdk-amd64/lib/server/libjvm.so
#4  0x00007fffffffdfd0 in ?? ()
#5  0x00007ffff785af19 in VM_Version::get_processor_features() () from
/usr/lib/jvm/java-9-openjdk-amd64/lib/server/libjvm.so
Backtrace stopped: previous frame inner to this frame (corrupt stack?)


I found this example here:  https://bugs.openjdk.java.net/browse/JDK-8183188


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?53733>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]