dub 0 Posted August 9, 2006 Report Share Posted August 9, 2006 I've seen the problem on and off on my embedded device and always though it was stack overflow related but last night nailed the problem to BoostC compiler error. Consider call to following function: ... ... lcd_printf("%3d m/sec", speed); ... ... Function is defined earlier in code and here is just the starting sequence of the function (note definition of "pi" variable, We will get ot that later). void lcd_printf( char *fmtptr, unsigned int val ) // JS - Accept unsigned by default { unsigned char pi = 0, bi, c, fill, baseOrBits, sign, mask; unsigned char buff[ 16 ]; // max length allowed is 16 bit pad; while( 1 ) { c = fmtptr[pi++]; if ( !c ) return; ............. ............ Variable fmtptr (string "%3d m/sec" is placed to address 0x0073 (bold in following memory dump. 0x0070 00 01 00 25 33 64 20 6D . 0x0078 2F 73 65 64 00 01 20 00 As we progress through the loop debugger clearly shows that local variable "pi" is stored at the location of NUL character in fmtptr string thus corrupting output to LCD screen and actually printing non printable character until first NUL char is encountered. 0x0070 00 01 00 25 33 64 20 6D 0x0078 2F 73 65 64 04 01 20 00 Please contact me if you need assistance in reproducing the bug. It caused me quite a lot of grief over the last week or so. Regards! Dub Bartolec Quote Link to post Share on other sites
Dave 0 Posted August 9, 2006 Report Share Posted August 9, 2006 Dub, ....As we progress through the loop debugger clearly shows that local variable "pi" is stored at the location of NUL character in fmtptr string thus corrupting output to LCD screen and actually printing non printable character until first NUL char is encountered. 0x0070 00 01 00 25 33 64 20 6D 0x0078 2F 73 65 64 04 01 20 00 It sounds nasty Please send a simple, but complete, project that can be built and run under the SourceBoost IDE debugger and we will investigate further. support@sourceboost.com Regards Dave Quote Link to post Share on other sites
Dave 0 Posted August 10, 2006 Report Share Posted August 10, 2006 Dub, Thanks for sending the project. This problem exists in V6.40 and previous versions. The problem is caused when a temporary string is passed in an inline function eg: void foo2( char *str ) { ..... ..... } inline void foo() { foo2( "hello" ); } The string only gets 1 byte allocated to it, so other variables then uses the same memory area causing corruption. Only temporary string data seems to be affected in this way. Regards Dave Quote Link to post Share on other sites
Dave 0 Posted August 10, 2006 Report Share Posted August 10, 2006 Dub (and all), There is now a compiler patch available to resolve this problem, it can be found on the SourceBoost Download page. Regards Dave Quote Link to post Share on other sites
dub 0 Posted August 11, 2006 Author Report Share Posted August 11, 2006 Dave and others, Tried the patch, and I am pleased to report that it fixed the problem reported few days ago. Thanks for providing fix so quickly, and keep up the good work. Regards! Dub Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.