librealsense icon indicating copy to clipboard operation
librealsense copied to clipboard

Random execution exceptions

Open danielw256 opened this issue 8 years ago • 16 comments

Required Info
Camera Model SR300 & D435
Firmware Version 3.21.0.0 & 5.08.15
Operating System & Version Win10 Pro version 1709 build 16299.19
SDK Version 2.9.0

Using VS2017, C++, COM DLLs, and threads, we have implemented the library. We are experiencing random execution exception crashes of 2 kinds (1) at the Windows message loop and (2) at a unknown code location (there is no debug info, even though all projects have PDB files and debug info). This is a legacy robot program that used to use GigE cameras, so we know our code is very stable. These exceptions make no sense especially at the Windows message loop. How can the message loop be running fine, then suddenly, the message loop doesn't have execution access? Could something be changing the page tables? We have no code that does that. Only standard C++ and WinAPI.

danielw256 avatar Jan 16 '18 15:01 danielw256

Hi @danielw256 Are you using one of the pre-compiled releases? If yes, would you be willing to provide a crash-dump (or several dumps) to Intel for analysis? We are not aware of any memory corruption in the library. Also, the hourglass API pattern should be preventing any issues that might be related to ABI-compatibility. All our internal tests, including long-running ones are stable. What is the reproduction rate you experience?

dorodnic avatar Jan 16 '18 18:01 dorodnic

I'm using my own debug VS2017 build with default cmake settings. Tomorrow, I can switch and provide you with the dumps. The message loop dump probably won't be much help. Hopefully, the unknown line code dump will help. But I don't know why VS2017 wont show me the line of code where it crashed, since the realsense2.pdb is in the execution directory. Maybe it's crashing within Windows. I probably get a crash every 5-15 minutes, even after I finish using the camera using pipe.stop(). My image snapping function returns, so all the stack camera variables should be cleaned up by destructors.

danielw256 avatar Jan 16 '18 19:01 danielw256

Yes, this does sound strange indeed. We will be happy to take a second look at the dump file, hopefully we will be able to help. One experiment I can think of would be to comment out the content of start and stop here. The logic is - if device_watcher remains alive, it can respond to somewhat random events in the system, like connection of removable media. Of course, a. it shouldn't crash b. it should have provided a call stack and c. device_watcher is stopped and destroyed once pipeline / context go out of scope.

dorodnic avatar Jan 16 '18 19:01 dorodnic

@dorodnic Where to upload the dump file? It crashes both during camera use and after close.

danielw256 avatar Jan 17 '18 16:01 danielw256

We don't have a good location. You can share it using google driver or Dropbox and send us the link ([email protected])

dorodnic avatar Jan 18 '18 17:01 dorodnic

@dorodnic Done. first 2 from windows message loop. 2nd 2 from unknown line.

danielw256 avatar Jan 18 '18 19:01 danielw256

Got it, will update early next week.

dorodnic avatar Jan 19 '18 21:01 dorodnic

Hello @danielw256 I have been looking into the files you provided, and so far can offer only very limited insight:

  1. I think evf4.dmp was not captured with the same version of librealsense as the rest since it doesn't match symbols for 2.9.0
  2. All crashes have threads related to realsense in the background, but as you pointed out the crash is not coming from them, and all they do is wait on some kernel objects.
  3. Some crashes seem to happen during streaming, some not during streaming. Please note that if you are properly disposing of all rs2 objects, all realsense threads should disappear (synchronously). The fact that you still see realsense threads when not streaming means that some rs2 objects are still around.
  4. Overall, I can confirm your observations regarding the message loop and the missing stack frame.

From here, I would suggest:

  1. Could you please enable realsense logging into file and us a low level (DEBUG or INFO) log to help us understand how you work with the camera?
  2. Could you please make sure that after streaming you destroy all realsense objects and check if the crash still occurs?

dorodnic avatar Jan 22 '18 16:01 dorodnic

@dorodnic Is there a list of objects that are destroyed automatically by the C++ destructor when they go out of scope and a list of objects that must be destroyed manually?

Before I sent you my dump files, I reconfigured my thread to never stop snapping. So the camera was taking synchronized RGB and depth images for all 4 dumps.

Also, my memory usage never significantly increases, so it's not a big object.

danielw256 avatar Jan 25 '18 12:01 danielw256

@dorodnic I tried to make my thread synchronization better. It still dumps at the windows message loop anymore and at an unknown location with no stack frame. I uploaded to my dropbox 4 more dump files with logging, and gave you access.

danielw256 avatar Jan 26 '18 11:01 danielw256

@dorodnic Crashes occur every 20 mins now.

danielw256 avatar Jan 29 '18 13:01 danielw256

Hi @danielw256 To answer your question on resource management - all RealSense resources are cleaned-up when the corresponding C++ object goes out of scope, there is no need for explicit clean-up. I saw the new files and looked over the logs, I will ask someone on the team to review the data for a second opinion.

dorodnic avatar Jan 30 '18 20:01 dorodnic

Hi @danielw256 I tried to load your crash dumps but they are not compatible with the symbols of 2.9.0, can you please verify you are working with the official release? If not can you reproduce with official release and send new dumps?

aangerma avatar Jan 31 '18 15:01 aangerma

@aangerma I redid the dumps and logs with the 2.9.0 official release build. I uploaded to dropbox and gave @dorodnic access. It seems the librealsense pipe.wait_for_frames(); and alignment functions overwrites our COM image virtual functions pointers.

danielw256 avatar Feb 01 '18 02:02 danielw256

I think librealsense and COM are just incompatible.

danielw256 avatar Feb 28 '18 22:02 danielw256

We had some old / bad COM files in our repo. Sorry.

danielw256 avatar Jul 03 '18 15:07 danielw256