Hi all,
I recently installed CCS 5.4.0.00091 after uninstalling my previous version 5.3.x. I then ran into some very strange behaviour when importing an existing project that has been running ok for over a year, using compiler version 4.9.1. I got the usual warning in CCS 5.4 that this compiler version was not currently installed, and that the effective compiler version therefore was version 5.0.6. I used Help/Install New Software to install version 4.9.2 and that appears to have fixed my problem.
However, I need to find out what the root-cause was and eventually upgrade my ARM Compiler Tools.
The root-cause appears to be a bug within the runtime-support implemention of the binary search algorithm, that is, the function "bsearch" as declared within header-file "stdlib.h". I believe the problem should be reproducible for anyone who have these or similar versions installed.
1. Grab the blinky project (C:\TI\controlSUITE\device_support\f28m35x\v150\F28M35x_examples_Master\blinky).
2. Add some heap-size (e.g., 1024) (Only for printf to highlight the problem).
3. Set compiler version to 4.9.2. or earlier.
4. Modify blinky.c to include stdlib.h and make a call to bsearch(). For example, modify the while(1) loop to read as follows:
Also, add a comparison function above the main():
5. Run the project. With the above, you should see the following printed to CCS console:
Turn on LED.
Perform binary search.
Found 32 at array position 3.
Turn off LED.
Turn on LED.
Perform binary search. .... And so on.
6. Now, for the interesting bit, please change the compiler version to 5.0.4, 5.0.6 or 5.1.1, and run it again. This time it will crash with a hard fault when calling bsearch() the first time.The crash seems to be be due to stack overflow that is, by stepping through the code, I can see that the bsearch algorithm seems to be goining into an infinite recursion, laying itself on the stack endlessly until a hard fault is provoked.
Am I being fooled by something else here? For example, mismatch between rts headers and lib. I don't get this, is the really a bug in the rts?
PS: I also attached my example project as a zip-file.
Best regards,
Christian