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; #$ENV{LD_PRELOAD} = "/lib/i686/nosegneg/libpthread.so.0"; #$ENV{LD_LIBRARY_PATH} = "/usr/java/jdk1.7.0/jre/lib/i386/server:/us +r/java/jdk1.7.0/jre/lib/i386/jli:/usr/java/jdk1.7.0/jre/lib/i386"; }; 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!" );

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 InlineJavaUserClassLoade +r 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: 0x00c044 +6c *** ======= 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]

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


In reply to Inline::Java JNI Crashing by tachyon-II

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.