This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: printf() stops working after some time


No opinions on this one?

On Fri, Oct 19, 2018 at 12:19:57PM +0200, Josef Wolf wrote:
> Hello,
> 
> I am using newlib (and its printf) for more than 15 years now.
> 
> Now I upgraded to 3.0.0 and see that printf() stops working once write()
> returns an error. Looks like printf() sets an error flag on the stream which
> needs to be cleared by clearerr().
> 
> Unfortunaltey, GCC optimizes printf calls with constant format strings to use
> puts() instead of printf. And puts() does NOT honor this error flag.
> 
> The result is that, once write() returns an error, only those optimized
> printf() 'calls' will be output.
> 
> Why are printf/puts inconsisten on the error handling?
> 
> Is there a way to "auto-clear" this error flag?
> 
> I have not seen this in older newlib releases.
> 
> 
> PS: As I investigated the above issue, I've seen that printf() and friends are
>     using malloc/realloc and things. I'm getting pretty nervous about malloc
>     usage, since this is an embedded system which is supposed to run for
>     really long term (years/decades) and fragmentation would be a major issue.
> 
>     Is it possible to disable malloc usage when compiling newlib?
> 
> -- 
> Josef Wolf
> jw@raven.inka.de

-- 
Josef Wolf
jw@raven.inka.de


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]