-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Destructor throwing exception 'std::system_error' what(): Unknown error 16777216. Should sensor be closed and stopped? #10420
Comments
UPDATE: Even with the second version above I still get the exception. |
Hi @sison54 If a function that has a block of code nested inside it is defined so that the function can be called by name elsewhere in the script to activate the nested code block, its opening line is typically defined as void () - for example, A small number of RealSense users who experienced errors when performing start and then stop found that the problem was resolved if they did pipe.start() and sensor.stop() instead of pipe.start() and pipe.stop() Also, if the problem was related to retrieving the depth scale value in real-time rather than caused by repeated start-stop then you could simply set the depth scale variable to the fixed numeric value of the L515's depth scale instead of retrieving it with an instruction. The L515's default depth scale is 0.000250 and this value does not change unless deliberately done so by a program instruction. |
Thanks for your reply, I will try doing pipe start and sensor stop to see if that solves the problem. It has nothing to do with the depth scale specifically. I just broke the problem down to the simplest case just to demonstrate the problem and to make it easier to debug. The same problem also happens in other similar functions where I am starting and stopping but I am getting frames, and setting options, etc. Th get depths scale is the simplest of the cases and the issue occurs. |
What I meant is that I have not previously seen functions that start with float instead of void. For example, this function definition in one of the RealSense SDK's C++ example programs: |
I am sorry for the confusion here, but what about this function, the one right above that you gave an example of: |
The align-advanced script is not important to this discussion. I am just using it to illustrate that in my experience, a function usually starts with 'void' instead of 'float'. For example: |
I updated my code example to include my object that contains a pipe and I returned 0 in cases where an exception is caught. Again, exceptions are never caught even though one is thrown. This is an indication that the throw happens in a destructor. I think the return value in this case is irrelevant as I don't think this has anything to do with the error. The point here is that some destructor in the library is throwing an exception, which crashes the application and gives no way to recover. |
The SDK's error handling documentation provides a note about destructors. https://dev.intelrealsense.com/docs/librealsense-error-handling-scheme Note Regarding Destructors: The only case when an exception will be handled internally without notifying the user, is as part of object destruction flow. For example, when the device object is being destroyed we might get system call failures due to the device being disconnected. Any such errors will be documented in the log but not risen to the user to avoid throw-in-destructor problems. My research could only find one past case though on this support forum at #7553 that discusses a potential destructor related error. |
I tried this, and got the same error. Whats expected workflow? Are pipes supposed to able to be started/stopped?
This doesnt seem to be the case since I am getting throw-in-destructor problems. |
Yes, you can start and stop pipes. A circumstance where an error can occur is if stop is called when a pipe is not currently active (as you cannot call stop before start). |
Here is the core dump stack trace:
|
There have been past cases on the 400 Series cameras where a piece of the computer's memory was consumed each time that a start-stop was performed (i.e a 'memory leak' that degrades performance as memory is consumed over time until the program becomes unstable or exits). #8091 is a C++ example of such a case. So it may be worth monitoring memory during the test-running of your application to see whether similar progressive memory consumption is occurring with the L515. |
I don't think its a memory issues. I did not see any memory usage that climb over time. Also it crashes at random, sometimes it takes 15 minutes sometime sit takes hours. I have a feeling its some sort of compatibility issue with my environment, although I have no evidence to prove that. For the moment I am just going to leave the pipe open. I ran for several days without stopping the pipe and saw no issues. This application will be running 24/7, so if I see any issues I will re evaluate. |
Okay, thanks very much @sison54 for the update. Let's keep this case open for a further time period to give you the opportunity to perform more long-run testing. Thanks again and good luck! |
Hi @sison54 Do you have an update about this case that you can provide, please? Thanks! |
I have no further update. Although I never found the root cause, leaving the pipe open is able to solve my problem as a workaround. As long as this doesn't cause any hardware issues in the long run this should be ok, until some reason a rises that I have to start and stop the pipe again. |
Thanks very much @sison54 for the update! As your workaround is acting as a solution for now, I will close the case. Please feel free to re-open it or start a new case at a future date if you need to because a problem occurs again. Thanks again! |
Issue Description
It seems that a destructor of some sort is throwing an exception that is terminating my application. It is not all the time and is very inconsistent, but I can get it to do it at least every few hours.
Here is the exception that I am getting when my application terminates:
The exception is not able to be caught in a try catch block as it seems to happen after certain objects are going out of scope. It's possible I may be doing something wrong here so I just wanted to see if there was a bug somewhere, a known issue, or user error on my part. I believe I may have fixed the problem, but I am not sure if this is correct.
In my examples I tried to narrow it down to the simplest thing. I am calling this function every 10 seconds in a loop just for testing this error.
Here is the code that fails, the exception never gets caught, but when the function scope ends, an exception is thrown and the application is terminated:
Here is how I seemed to fix it, I created an object that has
rs2::pipeline _pipe {}
as a member variable, and I make sure to stop and close the sensor:I have only been running with this solution for a few hours with no errors so far, but I am not 100% confident on the solution. What is the recommended way of closing and stopping the sensor, doing it manually, or letting it do it in the destructor? What about with the pipe, should it be stopped manually, or can the destructor do it?
Thanks!
The text was updated successfully, but these errors were encountered: