Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 8 months ago.
Program crashes after adding a few global variabes
I am using mbed online IDE to build my program developed for FRDM-KL25Z. While still in the development, I added a few global variables/objects. After adding a few global variables, data structures etc, the program build happens correctly. However after flashing the program into the target, the program crashes. It doesn't matter what data structures or variables I add. So I am suspecting that there might be some compiler/tool restriction etc. I also checked that the program size, RAM utilization etc (as produced by the online IDE) are well within limits of the device. i.e. Not even 50% of the the flash or RAM available in the device.
I am using Bernard Borredon's EEPROM (i2c based) library. Would this be a culprit. Although there may not be any connection between the crash and the library, I observed that the problem started occurring after adding this library. Also I have tested each program module separately, before integrating into my main program.
I am not attaching any program here because am not able to create a sample program that reproduces the problem.
-Hemant
3 Answers
8 years, 8 months ago.
The best guess is that you have a bug in your program.
The most likely cause is an issue with writing past the end of an array or using an uninitialized pointer. Both of those will normally cause a crash, both of them will be dependent on exactly where things are being placed in memory and so susceptible to change when you add variables.
In short, there is not known problems with the core system itself that would cause this. Unless you either provide the code or publish the project and provide a link there isn't a lot anyone can do to help.
8 years, 8 months ago.
Your program probably hardfaults, which you can debug by doing a crashdump. If you have a uVision license you can check out Debugging a crashed device with CMSIS-DAP which explains the process.
8 years, 8 months ago.
Hi Hemant I also use Bernard's I2C EEPROM library and initially got strange results, in my case due to not observing strict data types/sizing with correct EEPROM address offsets in my data structures. Pretty basic error on my part but these things happen. Chris
Thanks Chris. I was not getting strange results, but program crash at early stage. I studied Bernard's EEPROM code. It is nicely written. And I am directly interacting with Bernard. I have already passed EEPROM issues. Even my own program is thoroughly reviewed. Now I am strongly suspecting the RTOS initialization such as INITIAL_SP where there might be a hard fault, multi threading issue etc. -Hemant
posted by 13 Apr 2016