Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java: passing List<String> results in 'java/lang/NoSuchMethodError' #12324

Closed
berak opened this issue Aug 28, 2018 · 1 comment

Comments

@berak
Copy link
Contributor

commented Aug 28, 2018

  • OpenCV => 3.4.2
  • Operating System / Platform => Windows 64 Bit
  • Compiler => mingw64 / jdk 9

java code tried:

        Net net = Dnn.readNet(model);
        List<String> outNames = new ArrayList<String>();
        outNames.add("feature_fusion/Conv_7/Sigmoid");
        outNames.add("feature_fusion/concat_3");
        List<Mat> outs = new ArrayList<Mat>();
        net.forward(outs, outNames);

same problem with net.setInputNames(List<String>)

resulting in:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000005adbde1a, pid=2532, tid=3168
#
# JRE version: Java(TM) SE Runtime Environment (9.0+11) (build 9.0.1+11)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (9.0.1+11, mixed mode, tiered, compressed oops, g1 gc, windows-amd64)
# Problematic frame:
# V  [jvm.dll+0x37de1a]
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
#

---------------  S U M M A R Y ------------

Command Line: -Djava.library.path=c:\p\opencv\build\install\java SimpleSample

Host: Intel(R) Celeron(R) CPU  N2840  @ 2.16GHz, 2 cores, 1G,  Windows 10 , 64 bit Build 10240 (10.0.10240.16384)
Time: Tue Aug 28 08:16:16 2018 Mitteleuropäische Sommerzeit elapsed time: 9 seconds (0d 0h 0m 9s)

---------------  T H R E A D  ---------------

Current thread (0x000000fdf02a4000):  JavaThread "main" [_thread_in_vm, id=3168, stack(0x000000fdf1ca0000,0x000000fdf1da0000)]

Stack: [0x000000fdf1ca0000,0x000000fdf1da0000],  sp=0x000000fdf1d9f2a0,  free space=1020k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [jvm.dll+0x37de1a]
C  [opencv_java342.dll+0xf10ac]
C  [opencv_java342.dll+0xe1c69]
C  [opencv_java342.dll+0x5aba7]
C  0x000000fd8001919c

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  org.opencv.dnn.Net.setInputsNames_0(JLjava/util/List;)V+0
j  org.opencv.dnn.Net.setInputsNames(Ljava/util/List;)V+5
j  SimpleSample.main([Ljava/lang/String;)V+94
v  ~StubRoutines::call_stub

siginfo: EXCEPTION_ACCESS_VIOLATION (0xc0000005), reading address 0x0000000000000000


Register to memory mapping:

RIP=0x000000005adbde1a jvm.dll
RAX=0x0000000000000000 is an unknown value
RBX=0x000000fdf02a4000 is a thread
RCX=0x000000fdf02a4000 is a thread
RDX=0x00000000e3ad3c98 is an oop
java.lang.NoSuchMethodError 
{0x00000000e3ad3c98} - klass: 'java/lang/NoSuchMethodError'
RSP=0x000000fdf1d9f2a0 is pointing into the stack for thread: 0x000000fdf02a4000
RBP=0x000000fdf1d9f3b8 is pointing into the stack for thread: 0x000000fdf02a4000
RSI=0x0000000000000000 is an unknown value
RDI=0x000000fdf02a4218 is an unknown value
R8 =0x0000000000000000 is an unknown value
R9 =0x000000fdf1d9f3b8 is pointing into the stack for thread: 0x000000fdf02a4000
R10=0x000000fd91dc7c60 is an unknown value
R11=0x0000000000000000 is an unknown value
R12=0x000000fd91dc8000 is an unknown value
R13=0x0000000000000000 is an unknown value
R14=0x000000fdf1d9f568 is pointing into the stack for thread: 0x000000fdf02a4000
R15=0x0000000000000000 is an unknown value

after digging through all those onion layers, it turns out, the problem is here:

#define LIST_GET(ENV, LIST) ENV->GetMethodID(LIST, "get", "((I)Ljava/lang/Object;")

( typo, the method signature must be (I)Ljava.lang.Object;)

this gets called from here:

jmethodID m_get = LIST_GET(env, juArrayList);

and m_get is invalid(0), due to the typo.

so, we get a 'java/lang/NoSuchMethodError' from C++ code xD !

i'll do a pr later the day, and try to find a good place to add a test.

@berak

This comment has been minimized.

Copy link
Contributor Author

commented Aug 30, 2018

it's also used in other places in the dnn module, e.g. for List<MatOfInt> aka std::vector<MatShape>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.