Tool/software: TI-RTOS
There is a critical bug in the System_doPrint function of the xdc library (file: xdctools_3_50_05_12_core\packages\xdc\runtime\System.c.).
My setup:
- Processor: TMS320F28375D
- SYS/BIOS 6.70: 6.70.00.21
- XDCTools 3.50: 3.50.05.12
- CGTools 18.1.1.LTS
- CCS 8.2.0: 8.2.0.00007
The test code
SYS/BIOS app.cfg:
var System = xdc.useModule('xdc.runtime.System'); var SysMin = xdc.useModule('xdc.runtime.SysMin'); System.extendedFormats = "%$L%$S%$F%f";
Class with function:
class TestXdcPrintf { public: TestXdcPrintf(); virtual ~TestXdcPrintf(); uint16_t doPrint(void); private: static const int m_PRINTBUF_SIZE = 60; char m_printBuf[m_PRINTBUF_SIZE]; }; uint16_t TestXdcPrintf::doPrint(void) { char* printBufStart = m_printBuf; uint16_t requestedPrintLength = 0U; //initialize the buffer for (int idx = 0; idx < m_PRINTBUF_SIZE; idx++) { printBufStart[idx] = 0xFFFF; } requestedPrintLength = System_snprintf(printBufStart, m_PRINTBUF_SIZE, "Message: %$F%$S", "TestXdcPrintf", 41, "%08d:%08d%08d:%08d -> code of my message: ", 11, 22, 33, 44); return requestedPrintLength; }
The bug description
Short version: The error occurs while executing System_snprintf with extended formats when you use the "%$F%$S" format string.
There is a recursive call of System_doPrint. While processing the extended format with "System_extendFxn" the function writes inside the target buffer without respecting "n" - the size specifier.
Debug session in pictures
I added a small piece of code to catch the bug. There is a variable "catastrophicError" that shall never become true but it becomes true! See the following figures.
Intermediate solution
We created an intermediate solution by checking the "buf-pointer" against a precalculated end address. I hope there will be a better solution in the future and you can help.
Thank you for your help in advance.
Dirk