[ 
https://issues.apache.org/jira/browse/HDFS-14321?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16782214#comment-16782214
 ] 

Sahil Takiar commented on HDFS-14321:
-------------------------------------

Digging into this some more, I think {{hadoopRzOptions::byteBufferPool}} should 
be a global ref. If {{hadoopRzOptionsSetByteBufferPool}} simply created a local 
ref to {{hadoopRzOptions::byteBufferPool}} then the reference would be lost 
once the porcess execution returned back to Java. By using a global ref, we 
ensure that {{byteBufferPool}} does not get garbage collected by the JVM. Since 
the {{byteBufferPool}} is expected to live across calls to {{hadoopReadZero}}, 
using a local ref does not make sense.

This is based on my understanding of the JNI and the difference between local 
vs. global references: 
http://journals.ecs.soton.ac.uk/java/tutorial/native1.1/implementing/refs.html 
I'm not a JNI expert, so my understanding might be off, but this patch fixes 
the {{FATAL ERROR}}.

The second part of this patch is to add {{-Xcheck:jni}} to {{LIBHDFS_OPTS}} 
when running all the libhdfs ctests. The drawback here is that adding this 
pollutes the logs with a bunch of warnings about exception handling (see 
above). The benefit is that it ensures we don't make any changes to libhdfs 
that would results in more fatal errors. IMO I think we can live with the 
extraneous logging, but open to changing this if others feel differently.

> Fix -Xcheck:jni issues in libhdfs, run ctest with -Xcheck:jni enabled
> ---------------------------------------------------------------------
>
>                 Key: HDFS-14321
>                 URL: https://issues.apache.org/jira/browse/HDFS-14321
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>          Components: hdfs-client, libhdfs, native
>            Reporter: Sahil Takiar
>            Assignee: Sahil Takiar
>            Priority: Major
>         Attachments: HDFS-14321.001.patch
>
>
> The JVM exposes an option called {{-Xcheck:jni}} which runs various checks 
> against JNI usage by applications. Further explanation of this JVM option can 
> be found in: 
> [https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/clopts002.html]
>  and 
> [https://www.ibm.com/support/knowledgecenter/en/SSYKE2_8.0.0/com.ibm.java.vm.80.doc/docs/jni_debug.html].
>  When run with this option, the JVM will print out any warnings or errors it 
> encounters with the JNI.
> We should run the libhdfs tests with {{-Xcheck:jni}} (can be added to 
> {{LIBHDFS_OPTS}}) and fix any warnings / errors. We should add this option to 
> our ctest runs as well to ensure no regressions are introduced to libhdfs.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to