View Full Version : Diagnosing a crash
1452-Leo
14-02-2016, 00:55
My C++ code has been working perfectly except for the fact that every minute or so, the code will crash (robot code goes red but comms stay up) and then get restarted automatically. This whole process only results in 3 or so seconds of downtime, but it is pretty annoying. Is there a way to see what error the program is returning? It doesn't show up in the driver station, but could I SSH in and see it? Just a line number or stack trace would speed up the debugging process significantly. Thanks!
Also, I have some un-commented spaghetti code at the moment, which is why I'm not posting it here. Secondly, I tested out a blank program and it doesn't crash, so the error is in my code.
nighterfighter
14-02-2016, 00:59
While this isn't answering your question exactly, I've noticed that when our code crashes, 99% of the time we are trying to access something that doesn't exist.
I assume your code is not crashing randomly; It's happening when something triggers it. Are you pressing certain buttons or doing camera tracking when it crashes?
1452-Leo
14-02-2016, 01:06
While this isn't answering your question exactly, I've noticed that when our code crashes, 99% of the time we are trying to access something that doesn't exist.
I assume your code is not crashing randomly; It's happening when something triggers it. Are you pressing certain buttons or doing camera tracking when it crashes?
The code crashes with zero input. However, this is our first time using a USB camera with Imaq. I'll have to comment it all out and test it next practice. Thanks!
nighterfighter
14-02-2016, 01:10
When you say it crashes with zero input:
Does it crash moments after you go into teleop?
Or a few minutes after enabling teleop and driving around?
If the first situation: You have something being initialized that the code doesn't like. If the second, it's possible you may have a memory leak? But more likely if you're doing stuff with IMAQ, it is related to that.
You aren't accidentally dividing by zero are you? I had that problem in 2012 when using the camera for tracking; Sometimes when it lost the target it would give something a value of 0 and try to divide with it.
1452-Leo
14-02-2016, 01:17
When you say it crashes with zero input:
Does it crash moments after you go into teleop?
Or a few minutes after enabling teleop and driving around?
If the first situation: You have something being initialized that the code doesn't like. If the second, it's possible you may have a memory leak? But more likely if you're doing stuff with IMAQ, it is related to that.
You aren't accidentally dividing by zero are you? I had that problem in 2012 when using the camera for tracking; Sometimes when it lost the target it would give something a value of 0 and try to divide with it.
It crashes 30 seconds to a minute after enabling teleop, regardless of movement/action. I was thinking it could be a memory leak earlier today, but the Roborio's free RAM as shown on the Driver Station stayed constant at around 115 mb throughout the testing.
Here is my IMAQ code in my TeleopPeriodic:
IMAQdxGrab(session, frame, true, NULL);
if(imaqError != IMAQdxErrorSuccess) {
DriverStation::ReportError("IMAQdxGrab error: " + std::to_string((long)imaqError) + "\n");
} else {
if (reversed){
imaqFlip(frame,frame,FlipAxis_enum::IMAQ_VERTICAL_ AXIS);
} else {
imaqFlip(frame,frame,FlipAxis_enum::IMAQ_CENTER_AX IS);
}
CameraServer::GetInstance()->SetImage(frame);
}
As you can see, I am only using IMAQ to mirror the image stream on command, not do any processing with it. Would this cause any issues? Thanks again!
nighterfighter
14-02-2016, 01:20
I can't tell off the top of my head, sorry. The way to tell for sure is to comment out that part, but leave the camera plugged in and just view the stream on the dashboard.
If it doesn't crash, then it's something in your IMAQ code.
AustinSchuh
14-02-2016, 04:45
Here's a couple ideas for things to try.
1) Stop the robot code from starting up automatically and start it under GDB on the roboRIO. You'll then get good stack traces.
2) Enable core dumps. Once it crashes, copy the core dump back to your laptop and load it and the binary into GDB. You can then get a good stack trace.
1452-Leo
14-02-2016, 15:43
Here's a couple ideas for things to try.
1) Stop the robot code from starting up automatically and start it under GDB on the roboRIO. You'll then get good stack traces.
2) Enable core dumps. Once it crashes, copy the core dump back to your laptop and load it and the binary into GDB. You can then get a good stack trace.
Could you explain how to do either of these? Thanks!
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.