__memcpy_ssse3() segmentation fault - c++

i'm working with Opencv, trying to copy some frame that captured from web camera. when copying the frame, i'm getting segmentation fault in __memcpy_ssse3(), line 160 or 1675.
gdb shows:
0 __memmove_ssse3 () at
../sysdeps/i386/i686/multiarch/memcpy-ssse3.S:1675
1 0xb75ec6d0 in cv::Mat::copyTo (this=0xbfca3450, _dst=...) at
/home/david/opencv/OpenCV-2.4.2/modules/core/src/copy.cpp:181
2 0xb75984f6 in cv::Mat::Mat (this=0xbfca358c, img=0xb1300c90,
copyData=true) at
/home/david/opencv/OpenCV-2.4.2/modules/core/src/matrix.cpp:510
The function that calls it is cv::MAt::Mat(IplImg *I, bool copy).
When I'm opening USB camera or file, everything is perfect, but when trying to read the video stream from webcam, via IP, it crashes after a minute.
I'v try to build ffmpeg and opencv without ssse3 support, and my application compiled with -mno-seee3 flag too.
Opencv vesion is 2.4.2, but the problem exists in 2.3.1 too.
ffmpeg version is 11.1, same problem in 8.X.
gcc version is 4.6.3, Ubuntu's branch.
The processor is Intel core2.
Any hints?

Segmentation faults in SSE operations are due to misaligned memory. Try passing -mpreferred-stack-boundary=4 -mstackrealign to see if that clears it up. If it does then you need to examine your stack to find out which code is misaligning it.

Thank you all, solved.
There was a mistake in locking between threads, and somehow the memory was override or freed in other thread. After fixing the lock dependencies the problem of segfault solved.

Related

Segmentation fault using dlib with gpu

I just installed dlib and I created one project with the cpu introduction example and another one with the gpu introduction example. the first one is compiled and executed on my computer and the second one is compiled and executed on a linux server to use the Nvidia GC. For the cpu example I can compile and execute without any problem. For the gpu example, I can compile without any problem but when I execute it, the initialization is ok but when the network is training I have the first epoch done properly and then I have a segmentation fault. The method used is trainer.train_one_step(mini_batch_samples, mini_batch_labels);
I also tried to train a network using the cpu and then to import it to the gpu example using the deserialize method but I also have a segmentation fault when it tried to do the prediction. The method used for the prediction is std::vector<unsigned long> predicted_labels = tnet(training_images);
I have this problem even without changing anything in the example code so I don't understand why I have this segfault. If someone can help me I will be very grateful.
I apologize for this question but just in case this really stupid mistake happens to someone, I didn't installed the latest version of dlib and this was causing troubles. After installing the latest version it's working properly...

opencv memory leak in equalizeHist?

I am running a process in ~20000 images. It was crashing every time at a different point, so I decided to debug it.
After a few debugging I have realized about this:
I've just create a dummy function that equalizes an image and when it goes out of the scope it does not release all the memory.
I have tried with:
equalizedImage.release() but same result.
Any idea about what to do or if I am not managing something correctly??
(using Opencv version 2.4.9)
Thank you!!
The documentation doesn't indicate that the src and dest can be the same image.
I hate not to be able to comment for this, but I want to note a few things.
1) Windows' Task Manager memory usage indicator cannot be fully trusted for this purpose. The Process is free to keep some memory reserved for future use.
2) Please post the code that leaks so we can reproduce it properly. Possibly with tools like Valgrind the leak can be detected. At least that is better than the Task Manager.
3) Have you considered upgrading to the latest release of OpenCV to see if this behavior disappears?
4) I highly doubt that this has something to do with your crashes.
Your code is fine and should not cause any leak. The problem is somewhere else. However, there is common problem when linking openCV wrongly with your program (for example linking with MT while your program is MD or another wrong configurations) that cause a problem in releasing cv::Mat. This problem usually appears in the Debug mode and disappeared in the Release mode. so you may try to debug it in the debug mode. This problem may prevent Mat from being freed correctly.
BTW, what is the memory usage you are getting after 1000 epochs?

GCC links trigger seg fault when the program is executed

I have produced a program that works perfectly fine on Linux Mint and now i have to make it work on a IBM computer running on linux red hat. For the libraries i have put them into modules (i had to recompile SFML for red hat) but when i start my program, it provokes a segfault, here is what valgrind told me about that failure :
Process terminating with default action of signal 11 (SIGSEGV)
==30230== Access not within mapped region at address 0xE0
==30230== at 0x55B5974: sf::priv::GlxContext::GlxContext(sf::priv::GlxContext*) (in /workfs/dev/libs/SFML-2-2.1/build/lib/libsfml-window.so.2.1)
Just before the segfault i have this strange error : xrandr cannot load extension for display.
This error still occurs when i try to start SFML examples
Here is the code which provokes the segfault :
//segfault ;
this->window = new sf::RenderWindow(sf::VideoMode(this->width, this->height), this->title,sf::Style::Close, settings);
It looks like SFML cant create an OpenGL content because xrandr is whining, does someone have an idea ? Could someone bring me light upon my problem :D ?

PIX DirectX 11 Debug Pixel Error

I recently updated my DirectX 11 (C++) application for dual-monitor, dual-window support. Ever since then, when I try to debug any pixel in the PIX debugger, I get the following error:
A call that previously succeeded failed during playback:
EID: 1375
Call: IDXGIFactory::CreateSwapChain()
HRESULT: DXGI_ERROR_INVALID_CALL
For more information click 'Help'.
I am no longer using D3D11CreateDeviceAndSwapChain, but instead using D3D11CreateDevice and then CreateSwapChain to create separate swap chains for each of two windows (one per monitor). I used the SDK sample MultiMon10 as a reference when making my changes, however I can still debug pixels without error when running the MultiMon10 sample project through PIX. So it can't just be a matter of "CreateSwapChain" not being PIX-friendly.
Any ideas what could be causing this error? Debugging pixels and stepping through shaders has helped me out a lot in the past and I'd hate to lose that capability.
Seems like I am hitting the same problem. It also happens with Visual Studio 2012 Graphics Debug. Must be something with CreateSwapChain in DX Debug mode.
I've been using Intel's GPA tool instead to workaround this issue. I find it very useful. It can be used to debug on the same machine or through a client/server model.

Error: Terminating app due to uncaught exception 'NSInternalInconsistencyException'

I am getting error on debugger:
cocos2d: CCTexture2D. Can't create Texture. UIImage is nil
cocos2d: Couldn't add image:bg.png in CCTextureCache
* Assertion failure in -[StartTrain addChild:z:tag:], /Users/nishant/Downloads/AnimBear 2/libs/cocos2d/CCNode.m:370
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Argument must be non-nil'
An Application runs on simulator but not on actual device.
please help.. :(
Is your device an iPhone 4? Someone on the cocos2d-iphone forums had a similar problem; this thread documents what he tried and what ended up solving the problem. It's possible that the hd version of the image you are trying to load is too large or is not in the correct format.
If you are running 0.99.5 rc1, you may also want to upgrade to the release version of 0.99.5, as mentioned in this thread about another similar problem.
I had a similar problem, the name of the file was correct, format was correct (was .png) and I had cleaned in xcode and deleted the app from my iphone, yet I still had the error.
As someone else said in the comment, the size of the sprite just might be too large (depending on your memory usage). For me I had all sorts of sprites and stuff flying over the screen. So I resized it and it currently runs perfect.
Also I was using a iPhone 3G.