-
Notifications
You must be signed in to change notification settings - Fork 737
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
SIGSEGV crash opencv bytedeco #990
Comments
It sounds like the memory of rawImage may be getting deallocated prematurely. Make sure this isn't happening, for example, by making a clone of if with |
Hey @saudet , I'll double check once and get back. Thanks |
Well that didn't work either. The funny thing is that the same piece of code is working in intellij on MacOS X. |
There may be something wrong with the pthread implementation on that machine? Have you tried to disable OpenCV's threading? |
I see, would this do the trick ? http://bytedeco.org/javacv/apidocs/org/bytedeco/javacv/Parallel.html |
It could help but, try to disable OpenCV's threading first see if that helps. |
can you give me some pointers on how to do it ? Thanks! |
Calling |
Thanks, I will try it and update here. |
@saudet That didn't work either. Although the crash report has changed a bit
|
I just tried without multi threading, to make sure its a threading problem. But on the main thread too, I got the aforementioned crash. Is there something wrong the way I am trying to convert image to gray ? Code snippet :
|
The size of the output Mat is not the same as the input Mat, so you cannot use the same for both. |
I see, I was able to use this with opencv.jar built from source using opencv repository. Let me adjust the size and get back here |
Okay it's working on adjusting the size in a single threaded application. But multi threading is still a problem. |
You won't be able to use the same output Mat from multiple threads either. In general, OpenCV isn't thread-safe. |
okay, noted. But do you think you could help me with outside JVM crashes ? Still kinda stuck with the multi threading flow, or if there is an alternative to improving processing speed. I am open to any suggestions too! |
Alternatively, I tried moving all of the grayscale processing to a single thread. I deployed the changes to tomcat, even using the single thread grayscale processing works for only 2 or 3 requests. Grayscaling code snippet :
I am getting the following crash
|
You're deallocating memory from the Mat before you use it, that won't work. Make sure to deallocate the memory only after you're done with it. |
Hey @saudet , are you referring to BytePointer de-allocation ? |
@saudet You're awesome! removing deallocation of byte pointer's removed the problem with single threaded application. I will check in a multi threaded environment again and come back. In the meanwhile, just releasing the Mat object later on in the code flow be enough to clear bytePointers as well ? |
No, releasing the Mat won't release the BytePointer. |
Roger that, I'll refractor some of my code and see what's the best that can be achieved. In the meanwhile I'll also check for any out of JVM crashed in multi threaded applications. Give me 48 hours, before I can confirm on closing this ticket. You've been an amazing help as usual. |
@saudet problem resolved. For anyone else looking for the solution of the aforementioned issue, using
resolved the crash issue. Thank you for all the help :) |
It doesn't work without |
inadvertently I followed if it works don't touch it, haha I'll get back on this. |
update : it works without setNumThreads(1) too. To resolve the aforementioned issue :
Additional : Thanks @saudet |
Hey!
Environment description :
Summary : Java ( war ) deployed on tomcat inside a docker container.
Details :
Java :
openjdk version "1.8.0_275"
OpenJDK Runtime Environment (build 1.8.0_275-b01)
OpenJDK 64-Bit Server VM (build 25.275-b01, mixed mode)
Tomcat
tomcat 8
Docker container
tomcat:8
Case scenario :
Trying to access the following byte deco API from multiple threads ( created using executorService in java )
Byte deco api :
Code snippet of executor service section :
ExecutorService executorService = Executors.newFixedThreadPool(2);
Problem :
Outside JVM crash, with the following trace
any idea's why this could be happening ? If there is something more that I can share or explain further, do let me know!
Cheers!
The text was updated successfully, but these errors were encountered: