Warnings reported with -Xcheck:jni when using Memory class

Ouverte
#1,262 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
25/100
Type d'issue
Bug
Clarté
À clarifier
Activité
À l'abandon
Stack technique
java

Piste de recherche

Reproduisez le rapport avec le snippet Java fourni, OpenJDK 11.0.8, JNA 5.6.0 et -Xcheck:jni. Commencez par suivre Native.loadNativeDispatchLibraryFromClasspath et Memory.malloc dans Native.java et Memory.java ; le travail est terminé lorsqu’il est déterminé si les avertissements JNI signalés peuvent être éliminés et que le résultat est couvert par un test de régression.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

To reproduce, run the following snippet with -Xcheck:jni VM argument (I'm running with OpenJDK 11.0.8):

import com.sun.jna.Memory;

public class Test {

	public static void main(String[] args) {
		Memory m = new Memory(1024L);
		System.out.println(m);
	}

}

Observe output:

Warning: SIGINT handler expected:libjvm.so+0xc14f00  found:0x0000000000000001
Running in non-interactive shell, SIGINT handler is replaced by shell
Signal Handlers:
SIGSEGV: [libjvm.so+0xc14d00], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGBUS: [libjvm.so+0xc14d00], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGFPE: [libjvm.so+0xc14d00], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGPIPE: [libjvm.so+0xc14d00], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGXFSZ: [libjvm.so+0xc14d00], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGILL: [libjvm.so+0xc14d00], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGUSR2: [libjvm.so+0xc14b80], sa_mask[0]=00100000000000000000000000000000, sa_flags=SA_RESTART|SA_SIGINFO
SIGHUP: [libjvm.so+0xc14f00], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGINT: SIG_IGN, sa_mask[0]=00000000000000000000000000000000, sa_flags=none
SIGTERM: [libjvm.so+0xc14f00], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
SIGQUIT: [libjvm.so+0xc14f00], sa_mask[0]=11111111011111111101111111111110, sa_flags=SA_RESTART|SA_SIGINFO
WARNING: JNI local refs: 33, exceeds capacity: 32
	at java.lang.ClassLoader$NativeLibrary.load0([email protected]/Native Method)
	at java.lang.ClassLoader$NativeLibrary.load([email protected]/ClassLoader.java:2442)
	at java.lang.ClassLoader$NativeLibrary.loadLibrary([email protected]/ClassLoader.java:2498)
	- locked <0x00000000ff401e20> (a java.util.HashSet)
	at java.lang.ClassLoader.loadLibrary0([email protected]/ClassLoader.java:2694)
	at java.lang.ClassLoader.loadLibrary([email protected]/ClassLoader.java:2627)
	at java.lang.Runtime.load0([email protected]/Runtime.java:768)
	at java.lang.System.load([email protected]/System.java:1837)
	at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1018)
	at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:988)
	at com.sun.jna.Native.<clinit>(Native.java:195)
	at com.sun.jna.Memory.malloc(Memory.java:722)
	at com.sun.jna.Memory.<init>(Memory.java:114)
	at test.Test.main(Test.java:9)
WARNING in native method: JNI call made without checking exceptions when required to from CallStaticObjectMethod
	at java.lang.ClassLoader$NativeLibrary.load0([email protected]/Native Method)
	at java.lang.ClassLoader$NativeLibrary.load([email protected]/ClassLoader.java:2442)
	at java.lang.ClassLoader$NativeLibrary.loadLibrary([email protected]/ClassLoader.java:2498)
	- locked <0x00000000ff401e20> (a java.util.HashSet)
	at java.lang.ClassLoader.loadLibrary0([email protected]/ClassLoader.java:2694)
	at java.lang.ClassLoader.loadLibrary([email protected]/ClassLoader.java:2627)
	at java.lang.Runtime.load0([email protected]/Runtime.java:768)
	at java.lang.System.load([email protected]/System.java:1837)
	at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1018)
	at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:988)
	at com.sun.jna.Native.<clinit>(Native.java:195)
	at com.sun.jna.Memory.malloc(Memory.java:722)
	at com.sun.jna.Memory.<init>(Memory.java:114)
	at test.Test.main(Test.java:9)
allocated@0x7ffff0510730 (1024 bytes)

Seen with jna-5.6.0.jar (latest I could find from maven: https://mvnrepository.com/artifact/net.java.dev.jna/jna).

Background:

We observe those warnings in our Eclipse based product (when checking for JNI problems with -Xcheck:jni), coming from SVN plug-ins:

WARNING in native method: JNI call made without checking exceptions when required to from CallStaticObjectMethod
	at java.lang.ClassLoader$NativeLibrary.load0([email protected]/Native Method)
	at java.lang.ClassLoader$NativeLibrary.load([email protected]/ClassLoader.java:2442)
	at java.lang.ClassLoader$NativeLibrary.loadLibrary([email protected]/ClassLoader.java:2498)
	- locked <0x00000005007d6730> (a java.util.HashSet)
	at java.lang.ClassLoader.loadLibrary0([email protected]/ClassLoader.java:2694)
	at java.lang.ClassLoader.loadLibrary([email protected]/ClassLoader.java:2627)
	at java.lang.Runtime.load0([email protected]/Runtime.java:768)
	at java.lang.System.load([email protected]/System.java:1837)
	at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:761)
	at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:736)
	at com.sun.jna.Native.<clinit>(Native.java:131)
	at com.sun.jna.Pointer.<clinit>(Pointer.java:41)
	at org.tmatesoft.svn.core.internal.util.jna.SVNLinuxUtil.<clinit>(SVNLinuxUtil.java:33)
Langage dominant
Java
Étoiles
8.9k
Forks
1.7k
Merge moyen
7 j 18 h
PR mergées (30 j)
2

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de java-native-access/jna

Toutes les issues de java-native-access/jna

Issues similaires

Plus d'issues Java

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.