JNI segfault on exit
[email protected] (GP2U Telehealth) Tue, 29 Jul 2014 01:52:37 +1000
| Newsgroups | perl.inline |
|---|---|
| Message-ID | <CAKniZoS=Lc_4TPWZOFp405J6N3PZV+rBYe+2g-T4tp5pv-QmaQ@mail.gmail.com> |
--047d7b86e8ba8a529a04ff42e93b
Content-Type: text/plain; charset=UTF-8
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
--047d7b86e8ba8a529a04ff42e93b
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><pre class=3D"" style=3D"white-space:pre-wrap;color:rgb(0,=
0,0)"><p style=3D"font-family:'Times New Roman';font-size:medium;wh=
ite-space:normal">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.</p>
<div class=3D""><tt class=3D""><span style=3D"font-family:'Times New Ro=
man';font-size:medium;white-space:normal">Anyone got a pointer to how t=
o avoid/fix this?</span></tt></div><div class=3D""><tt class=3D""><br></tt>=
</div>
<div class=3D""><tt class=3D"">[root@w32 JNI]# cat Hello.java JNICrash.pm <=
a href=3D"http://jni.pl">jni.pl</a>
public class Hello {
String Message;
public Hello(
String Message
) {
this.Message =3D Message;
}
public int speak() {
System.out.println( this.Message );
return 0;
}
}
package JNICrash;
use strict;
use warnings;
BEGIN {=20
$ENV{CLASSPATH} =3D '.';
$ENV{PERL_INLINE_JAVA_JNI} =3D 1;
sub CrashNBurn {
my ($msg) =3D @_;
use Inline (
Java =3D> 'STUDY',
STUDY =3D> [ 'Hello' ],
DEBUG =3D> 1, #5,
DIRECTORY =3D> '/tmp/',
PACKAGE =3D> 'main',
);
my $java =3D new Hello( $msg );
$java->speak();
#undef $java;
}
1;
#!/bin/env perl
use strict;
use lib '.';
use JNICrash;
JNICrash::CrashNBurn( "Hello, world!" );
</tt></div><font size=3D"-1"><div class=3D"" style=3D"padding:0px;margin:0p=
x"><a href=3D"http://perlmonks.org/?abspart=3D1;displaytype=3Ddisplaycode;n=
ode_id=3D1094297;part=3D1" style=3D"font-size:smaller;color:rgb(51,51,153)"=
>[download]</a></div>
</font></pre><p style=3D"color:rgb(0,0,0);font-family:'Times New Roman&=
#39;;font-size:medium">Which runs fine when $ENV{PERL_INLINE_JAVA_JNI} =3D =
0 but produces this when PERL_INLINE_JAVA_JNI =3D 1</p><pre class=3D"" styl=
e=3D"white-space:pre-wrap;color:rgb(0,0,0)">
<div class=3D""><tt class=3D"">[root@w32 JNI]# ./<a href=3D"http://jni.pl">=
jni.pl</a>=20
[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 **=
*
=3D=3D=3D=3D=3D=3D=3D Backtrace: =3D=3D=3D=3D=3D=3D=3D=3D=3D
/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]
=3D=3D=3D=3D=3D=3D=3D Memory map: =3D=3D=3D=3D=3D=3D=3D=3D
[snip]
</tt></div><font size=3D"-1"><div class=3D"" style=3D"padding:0px;margin:0p=
x"><a href=3D"http://perlmonks.org/?abspart=3D1;displaytype=3Ddisplaycode;n=
ode_id=3D1094297;part=3D2" style=3D"font-size:smaller;color:rgb(51,51,153)"=
>[download]</a></div>
</font></pre><p style=3D"color:rgb(0,0,0);font-family:'Times New Roman&=
#39;;font-size:medium">This happens on CentOS 5 & 6 with versions of Pe=
rl 5.10, 5,12, 5,18. Inline is 0.53</p><p style=3D"color:rgb(0,0,0);font-fa=
mily:'Times New Roman';font-size:medium">
Dr James Freeman</p><div><div dir=3D"ltr"><div><br></div></div></div>
</div>
--047d7b86e8ba8a529a04ff42e93b--