develooper Front page | perl.inline | Postings from July 2014

JNI segfault on exit

From:
GP2U Telehealth
Date:
July 28, 2014 15:52
Subject:
JNI segfault on exit
Message ID:
CAKniZoS=Lc_4TPWZOFp405J6N3PZV+rBYe+2g-T4tp5pv-QmaQ@mail.gmail.com
Using Inline::Java and the JVM everything is fine. If JNI is invoked
then it works, but on exit segfaults tyring to invalidate a non
existant pointer.
Anyone got a pointer to how to avoid/fix this?

[root@w32 JNI]# cat Hello.java JNICrash.pm jni.pl
public class Hello {
  String Message;
  public Hello(
    String Message
  ) {
    this.Message = Message;
  }
  public int speak() {
    System.out.println( this.Message );
    return 0;
  }
}

package JNICrash;

use strict;
use warnings;
BEGIN {
  $ENV{CLASSPATH} = '.';
  $ENV{PERL_INLINE_JAVA_JNI} = 1;

sub CrashNBurn {
  my ($msg) = @_;
  use Inline (
    Java       => 'STUDY',
    STUDY      => [ 'Hello' ],
    DEBUG      => 1, #5,
    DIRECTORY  => '/tmp/',
    PACKAGE    => 'main',
  );
  my $java = new Hello( $msg );
  $java->speak();
  #undef $java;
}
1;

#!/bin/env perl

use strict;
use lib '.';
use JNICrash;
JNICrash::CrashNBurn( "Hello, world!" );
[download] <http://perlmonks.org/?abspart=1;displaytype=displaycode;node_id=1094297;part=1>

Which runs fine when $ENV{PERL_INLINE_JAVA_JNI} = 0 but produces this when
PERL_INLINE_JAVA_JNI = 1

[root@w32 JNI]# ./jni.pl
[perl][1] validate done.
[perl][1] Starting load.
[perl][1] starting JVM...
[perl][1] JNI mode
[perl][1] using jdat cache
[perl][1] load done.
[java][1] loading InlineJavaUserClassLink via InlineJavaUserClassLoader
Hello, world!
[perl][1] killed by natural death.
[perl][1] JVM owner exiting...
[perl][1] exiting with 0
*** glibc detected *** perl: munmap_chunk(): invalid pointer: 0x00c0446c ***
======= Backtrace: =========
/lib/libc.so.6[0xa10e31]
perl(Perl_safesysfree+0x21)[0x80cde41]
perl(perl_destruct+0x200)[0x807a690]
perl(main+0xf3)[0x805fff3]
/lib/libc.so.6(__libc_start_main+0xe6)[0x9b6d26]
perl[0x805fe61]
======= Memory map: ========
[snip]
[download] <http://perlmonks.org/?abspart=1;displaytype=displaycode;node_id=1094297;part=2>

This happens on CentOS 5 & 6 with versions of Perl 5.10, 5,12, 5,18. Inline
is 0.53

Dr James Freeman



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About