* [ECOS] AW: probably simple problem: ASSERT in Cyg_StdIostream
@ 2006-04-25 5:43 Manfred Wölfel
2006-04-25 7:33 ` Andrew Lunn
0 siblings, 1 reply; 3+ messages in thread
From: Manfred Wölfel @ 2006-04-25 5:43 UTC (permalink / raw)
To: ecos-discuss
In the case of buffered IO, the constructor of Cyg_StdioStream
constructs a Cyg_StdioStreamBuffer object io_buf. The constructor of
Cyg_StdioStreamBuffer calls Cyg_StdioStreamBuffer::set_buffer that may
fail for lack of memory. The returned error is silently ignored in the
constructor of Cyg_StdioStreamBuffer. In this case the constructor of
Cyg_StdioStream gives up, before the magic value is set.
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [ECOS] AW: probably simple problem: ASSERT in Cyg_StdIostream
2006-04-25 5:43 [ECOS] AW: probably simple problem: ASSERT in Cyg_StdIostream Manfred Wölfel
@ 2006-04-25 7:33 ` Andrew Lunn
[not found] ` <444DE138.8060605@web.de>
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Lunn @ 2006-04-25 7:33 UTC (permalink / raw)
To: Manfred W?lfel; +Cc: ecos-discuss
On Tue, Apr 25, 2006 at 07:43:16AM +0200, Manfred W?lfel wrote:
> In the case of buffered IO, the constructor of Cyg_StdioStream
> constructs a Cyg_StdioStreamBuffer object io_buf. The constructor of
> Cyg_StdioStreamBuffer calls Cyg_StdioStreamBuffer::set_buffer that may
> fail for lack of memory. The returned error is silently ignored in the
> constructor of Cyg_StdioStreamBuffer. In this case the constructor of
> Cyg_StdioStream gives up, before the magic value is set.
So what are you suggesting? What is the fix? Could you provide a
patch?
Thanks
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [ECOS] AW: probably simple problem: ASSERT in Cyg_StdIostream
[not found] ` <444DE138.8060605@web.de>
@ 2006-04-26 13:44 ` Andrew Lunn
0 siblings, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2006-04-26 13:44 UTC (permalink / raw)
To: Manfred W?lfel; +Cc: Andrew Lunn, eCos Disuss
On Tue, Apr 25, 2006 at 10:43:36AM +0200, Manfred W?lfel wrote:
> No, I'm referring to
> http://ecos.sourceware.org/ml/ecos-discuss/2005-04/msg00103.html and the
> like. This is not the only topic that has been raised as a result of
> that problem. I just wanted to make people that face this problem aware
> of the need to break in Cyg_StdioStreamBuffer::set_buffer. But if you
> ask me for it, we have to give up completely, if memory allocation fails:
>
> Index: packages/language/c/libc/stdio/current/include/streambuf.inl
> ===================================================================
> RCS file:
> /cvs/ecos/ecos/packages/language/c/libc/stdio/current/include/streambuf.inl,v
> retrieving revision 1.6
> diff -u -r1.6 streambuf.inl
> --- packages/language/c/libc/stdio/current/include/streambuf.inl
> 23 May 2002 23:07:16 -0000 1.6
> +++ packages/language/c/libc/stdio/current/include/streambuf.inl
> 25 Apr 2006 08:41:32 -0000
> @@ -92,7 +92,8 @@
> // unnecessary, but it is to ensure a defined state if e.g. the malloc
> // in set_buffer() should fail
>
> - (void)set_buffer(size, new_buffer);
> + Cyg_ErrNo err = set_buffer(size, new_buffer);
> + CYG_ASSERT(err == ENOERR, "insufficient memory");
> } // Cyg_StdioStreamBuffer constructor
>
>
> Andrew Lunn wrote:
> >On Tue, Apr 25, 2006 at 07:43:16AM +0200, Manfred W?lfel wrote:
> >
> >>In the case of buffered IO, the constructor of Cyg_StdioStream
> >>constructs a Cyg_StdioStreamBuffer object io_buf. The constructor of
> >>Cyg_StdioStreamBuffer calls Cyg_StdioStreamBuffer::set_buffer that may
> >>fail for lack of memory. The returned error is silently ignored in the
> >>constructor of Cyg_StdioStreamBuffer. In this case the constructor of
> >>Cyg_StdioStream gives up, before the magic value is set.
I don't think throwing an assert is the correct fix. It looks like
Cyg_StdioStream::initialize returns ENOMEM when the buffer cannot be
created. The constructor needs to return this error code so what ever
needs the stream knows there was no memory and propergate on the
error.
Andrew
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-04-26 13:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-25 5:43 [ECOS] AW: probably simple problem: ASSERT in Cyg_StdIostream Manfred Wölfel
2006-04-25 7:33 ` Andrew Lunn
[not found] ` <444DE138.8060605@web.de>
2006-04-26 13:44 ` Andrew Lunn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).