This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos 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]

[kindof SOLVED] AW: probably simple problem: ASSERT in Cyg_StdIostream


Hi,


I got it working.

> Von: ecos-discuss-owner@ecos.sourceware.org
> 
> Hi, 
> 
> ...
> > > ASSERT FAIL: <8>stream.inl[109]cyg_bool 
> > > Cyg_StdioStream::trylock_me() Stream
> > > object is not a valid stream!
> > 
> > It seems to be the same problem as mentioned here, but there 
> > was no reply:
> > http://sources.redhat.com/ml/ecos-discuss/2003-05/msg00447.html
> > 
> > Here's the code which causes the assert:
> > 
> > void cyg_user_start() {
> >    unsigned int day;
> >    sscanf("1", "%d", &day);
> 
> I got some more information: the assert hits because neither 
> the magic_code of stdin nor of stdout are set correctly. They 
> aren't set because for both buffer_size==-1 and 
> WANT_BUFFERED_IO is true in Cyg_StdioStream::initialize(). 
> CYG_LIBC_STDIO_BUFSIZE has the default value of 256. 

buffersize returns -1 because the malloc() in setbuf() failed and returned 0, because in dlmalloc.cxx try_alloc() is arenabase==NULL.
Setting CYGSEM_LIBC_STDIO_DYNAMIC_SETVBUF to false solved the problem for me.
Calling malloc() later on in my application works. So something is wrong there.

To sum it up again:

I have an ecos config with threads, file IO, malloc and no POSIX compat.
sscanf("1", %d", &some_integer); stops with an assert: 
ASSERT FAIL: <8>stream.inl[109]cyg_bool Cyg_StdioStream::trylock_me() Stream
object is not a valid stream!

This assert ensures that magic_validity_word in Cyg_StdioStream has the correct value.
This isn't the case for stdin and stdout. Both are buffered and require a buffer. But during constructing these two objects it was not possible to malloc() the memory for their buffer, because in dlmalloc.cxx try_malloc() is arenabase==NULL and so malloc() returned 0, and the magic_validity_word wasn't set.
Then the first time this assert is checked for these two stream objects, it can't be fullfilled (this is here in flush_all_but(), but this doesn't actually matter much I think)  and the application stops. 

Can you reproduce this problem ?

Alex

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


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