I was downloading my code and I got this error on the brain.
I have never seen this issue before. I have already deleted all the programs and done a build all and full upload. Any help would be great!
1069B - Argonauts
I was downloading my code and I got this error on the brain.
I have never seen this issue before. I have already deleted all the programs and done a build all and full upload. Any help would be great!
1069B - Argonauts
I’ll write up a tutorial on how to debug these later
Step 1: Make sure you are downloading the correct program
In the meantime though, know that you’re probably getting this by dereferencing a null pointer somewhere.
It would be helpful for us in any case to know a little more about what you’re doing.
This is called a segfault. It is common, and is due to programmer error.
It is caused whenever you do something illegal in runtime that the compiler didn’t catch.
The most common cases are pointer mistakes (such as using a null or dangling pointer), array mistakes (accessing an out-of-bounds array element) or other runtime mistakes.
Until hotel comes out with his official guide, here is the code that you can run which tells you exactly where in the code the segfault happened:
arm-none-eabi-addr2line -faps -e ./bin/hot.package.elf <segfault addresses>
where the <segfault addresses>
is the PC number that showed on your screen.
If you have the robot plugged into the computer and the terminal is open, it will print the stacktrace of the segfault to the terminal. What this means is that it tells you the memory address of each nested function until you get to the problematic line, it basically tells you what called the function.
If you have those numbers, insert them at the end of the command to see a trace.
Note that you may have to switch ./bin/hot.package.elf
to ./bin/monolith.elf
depending if you have hot/cold enabled.
First thanks for all the input and sorry for not adding a lot of detail in the original post. I was just uploading my normal competition code. The updates to the code from the last working version was I changed all of the .h headers I have created to .hpp files. I have also changed some function prototypes so the parameters are const. Based off of @theol0403’s response the issue I believe is that the program is attempting to change a const value.
For the debugging does the brain have to be connected or can it be done over the controller?
Thanks for the Help!
That probably isn’t your problem.
Const is simply a flag to your compiler that the variable shouldn’t change. It is verified during compile-time, so you should not be able to compile if your issue is what you say it is.
If you happen to be tricking the compiler by using pointers or casts such as const_cast
, then that should not cause a segfault because memory is memory, and tricking the compiler to write to a variable that was marked as const simply changes the memory and does not violate any runtime concerns.
Your problem might be related to hot/cold linking, or stack overflow (recursion) or something like that.
All you need is the PC number (address number) to run the addr2line
tool on your computer. It does not do anything with the V5, it just looks at the compiled binary in your project.
To find the full stacktrace, you need to be connected to the robot terminal while the segfault happens. Currently PROS does not support wireless terminal. Therefore, to find the full trace (not just the single line address), you need to be connected to the USB to read those values on the terminal.
Once you have those values, you no longer need the v5.
So, unfortunately, I don’t have a brain with me at the moment to do a full stacktrace test, and I still don’t understand quit how to proform the command in a terminal. If you could show me an example that would be great! I was able to run the command that @theol0403 gave the example of.
I’m not sure what you mean about preforming the command in the terminal.
What you did was the correct way.
The result of your commend gave the location of the segfault to be stl_vector.h
. To find out what called the vector error, you need the full stacktrace. However, I can deduce what your problem is - you are accessing an out-of-bounds vector element. To try to change the segfault to a runtime error (which is more informative), do myVector.at(i)
instead of myVector[i]
. The former has bounds checking and will report what the error is to the terminal.
When you do have the full stack trace, you will have a list of memory locations. You can add them to the end of the addr2line
command, or you can completely omit any address to the command and after you run the command you can enter the addresses one by one.
When working with PROS I have never actually connected the brain to the computer directly it has always been though the controller. When I plug the brain into the computer where will it print to?
Are you telling me that you have never used the PROS terminal?
That is surprising, it is very useful for printing robot information to your computer. It’s where printf
and std::cout
outputs to.
To open it, there should be a button in the editor (PROS Terminal) or if you are using the CLI, type prosv5 terminal
.
Then you can print information from the robot to the terminal.
This stacktrace is a new feature with PROS that automatically prints to the terminal.
Unfortunately, wireless terminal (over the joystick) is not yet supported by PROS.
Yes, I have never used the PROS terminal. This is because I can’t download it to my brain directly (not wireless). So I have always used wireless downloading and created a very complicated GUI code to display all the needed information to the V5 screen. I haven’t had the time to debug the issue of why I can’t download directly but it is probably something I need to look into.
I have this same problem, except when running the command that helped solve the problem for the first person i got the following:
0x03874618: ?? ??:0
Any suggestions?