|
From: | Bernard Fouché |
Subject: | Re: [avr-libc-dev] snprintf bug ? |
Date: | Thu, 13 Oct 2005 10:34:34 +0200 |
User-agent: | Mozilla Thunderbird 1.0.2 (Windows/20050317) |
Russell Strong wrote:
The difference here between having 'static' or not for heading_tmp[] is, without 'static' to use the stack for memory storage, or, with 'static' to use the .bss segment (global variable). So that's RAM anyway and snprintf() does not care about what bunch of ram you use.Hi, I may have found a bug, I'm not sure if it would be with avr-libc or gcc. I'm using gcc-4.0.1, binutils-2.16.1 avr-libc-1.2.5. The problem is with the following function and snprintf, if heading_tmp is declared static it all works. If it is not declared static, snprintf puts garbage into heading_tmp ( lot of 0xb1 ). Am I doing something illegal? Do snprintf pointers need to be static? I couldn't find any thing like that in the Docs.
Usually the problem that you describe appears if:- the memory used in the stack is referenced after that the function has returned. It is not the case here. - the stack grew too much and something else scrapped it or the stack scrapped something else (some global variable just after the maximum allowable stack). Interrupt routines called while your function is being processed will grow the stack also. Obviously you have interrupt routines since you use cli()/sei().
- you ran in a yet unknown (and unlikely) compiler bug.Can you show the result of 'avr-size your_program.elf' and tell us what target you are using?
Bernard
[Prev in Thread] | Current Thread | [Next in Thread] |