java.lang.UnsupportedOperationException: Native object address is NULL in org.opencv.core.Mat.<init> (Bug #3613)
Description
Sporadically (quite rarely) receiving following exception in my java-application
Exception in thread "pool-4-thread-4" java.lang.UnsupportedOperationException: Native object address is NULL at org.opencv.core.Mat.<init>(Mat.java:424) at org.opencv.utils.Converters.Mat_to_vector_Mat(Converters.java:266) at org.opencv.utils.Converters.Mat_to_vector_vector_Point(Converters.java:500) at org.opencv.imgproc.Imgproc.findContours(Imgproc.java:5851)
Interesting, that if JVM launched in debug mode - this is not happen (issue relates to JVM?)
Tried on 1.7.0_45 and following one JVMs:
Java HotSpot(TM) 64-Bit Server VM; 1.7.0_51; 24.51-b03; mixed mode
Associated revisions
Merge pull request #3613 from asmorkalov:aarch64_tiff
History
Updated by Daniil Osokin almost 11 years ago
Hi, Arsen!
Looks like it's an issue in your code. Anyway, please provide code sample, that reproduce this problem. Also may be you could debug this issue? It will help a lot!
- Assignee changed from Vadim Pisarevsky to Arsen L
Updated by Arsen L almost 11 years ago
Daniil,
I made working example (see file attached) on which you may reproduce this issue.
My current assumption is that this exception depends on some in-JVM concurrency optimizations.
I realize, that calling MyOpenCvUtils.init() in BorderDetectorWorker.borderField() smells, but leave it as is: it looks like it will increase probability to reproduce issue.
Replace path to image to real path (Main.IMAGE_PATH) on your machine. Also, launch JVM with -Djava.library.path="path_to_opencv_java248.dll" and declare library "opencv-248.jar" for sources which I prepared.
Please, try to launh Main.main() with Main.THREAS_NUM equals to number of your machine CPU cores.
After about 5-10 minutes of running you should see following excetion in console:
Exception in thread "Thread-3" java.lang.UnsupportedOperationException: Native object address is NULL at org.opencv.core.Mat.<init>(Mat.java:424) at org.opencv.utils.Converters.Mat_to_vector_Mat(Converters.java:266) at org.opencv.utils.Converters.Mat_to_vector_vector_Point(Converters.java:500) at org.opencv.imgproc.Imgproc.findContours(Imgproc.java:5851) at BorderDetectorWorker.borderField(BorderDetectorWorker.java:22) at BorderDetectorWorker.run(BorderDetectorWorker.java:32) at java.lang.Thread.run(Unknown Source)
Note, that if laumced JVM in debug mode exception will not be thrown (so, there is no sense to debug code).
So, that's why I started to think this bug relates to Sun/Oracle JVM.
Please, let me know if you reproduced this issue or if I can assist you with something.
- File sources_to_reproduce.zip added
Updated by Arsen L almost 11 years ago
- Assignee changed from Arsen L to Daniil Osokin
Updated by Daniil Osokin almost 11 years ago
Thanks, Arsen. We will try to reproduce.
- Assignee changed from Daniil Osokin to Alexander Smorkalov
- Category changed from imgproc, video to java bindings
Updated by Sergei Nosov almost 11 years ago
- Status changed from New to Open
Updated by Piotr Betkier over 10 years ago
I observe the same issue in my application when using OpenCV concurrently. I'm using OpenCV 2.4.9 on Linux.
Updated by Maksim Shabunin over 9 years ago
Issue has been transferred to GitHub: https://github.com/Itseez/opencv/issues/4720