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]

Re: eCos2 stack base corrupted?


On Friday 03 January 2003 07:24 am, Fredrik Hederstierna wrote:
> I mailed to this list some weeks ago regarding problems when migrating
> from eCos 1.3.1 to eCos 2 (ARM target).
>
> The problem is that the stack base for a thread gets trashed somehow.
> This can happen after some hours and causes our system to crash.
>
> ASSERT FAIL: <1010>thread.inl[104]void Cyg_HardwareThread::check_stack()
> stack base not word aligned
>
> eCos 1.3.1 works perfecly but with eCos2 we get this problem.
> Any ideas what might be the problem?
>
> Best Regards,
> /Fredrik Hederstierna

Well, doesn't hurt to ask the obvious:

Did you increase your stack size ?  Ecos2 might use slightly more stack space, 
or you may have been overflowing your stack in the 1.3 version but just 
getting lucky.

You can enable stack checking as well in eCos - I'd recommend that you do 
that.  It's in the configtool:

Configuration
-> eCos kernel
--> Thread-related options
---> Measure stack usage

And you can use the code below in a small thread to periodically print the 
high water mark of the thread (note: code isn't tested, but it's essentially 
what you want)


#include <cyg/kernel/thread.h>
#include <cyg/kernel/thread.inl>
#include <cyg/kernel/kapi.h>

void mytask (CYG_ADDRWORD ignore_me)
{
  (void) ignore_me;

  while (1)
  {
    Cyg_Thread
      *cygThread;

    // dump the high water marks of all the threads
    for (cygThread = Cyg_Thread::get_list_head() ; cygThread != NULL ;
      cygThread = cygThread->get_list_next())
    {
      // prints thread TID, number of bytes used, number of bytes not
      // used, and name of thread, if any.
      printf ("%ld %d %d %s",
        (u32)cygThread,
        cygThread->measure_stack_usage(),
        cygThread->get_stack_size() - cygThread->measure_stack_usage(),
        cygThread->get_name()==NULL?"NULL":cygThread->get_name());
    }

    // delay a bit
    cyg_thread_delay (100);
  }
}

If you need more help on documentation of the C++ interface, I have a little 
UNOFFICIAL stuff at:

http://www.navosha.com/ecos

When working with the C++ API, make certain you can easily comment out your 
code, since there is no guarantee that C++ API will remain static.

-Rich



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


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