2008-06-03 11:07:31     Application crash resolved after increasing pthread stack size

Document created by Aaronwu Employee on Aug 6, 2013
Version 1Show Document
  • View in full screen mode

2008-06-03 11:07:31     Application crash resolved after increasing pthread stack size

Janiek Buysrogge (BELGIUM)

Message: 56629   

 

Hi,

 

We are developing an application on the BF561 with the 2006 kernel.

 

The application has several threads running, and one thread in particular which

 

can be started an will run until a condition will break it out of its while loop.

 

The functions that are called inside this thread worked fine for months, but suddenly

 

the application started crashing randomly when the functions inside this thread were

 

called. One of these functions consists of a couple of 1000 lines (I know, not a good thing,

 

but we will try to fix this) and has been constantly growing during the past months.

 

The crashes: had this line in it:

 

Kernel panic - not syncing: No CPLB Address Match and a large trace, which can

 

also be seen in other pthread posts.

 

After reviewing the code, the problem couldn't be found, because the crashes were so random.

 

The stack size that was given to this thread was set to 0x2000. After increasing this to 0x4000, the

 

problem disappeared, and we have not experienced it yet.

 

Because I am still not a 100% sure the problem is solved, I'd like to be sure if this is a good solution.

 

Could it be that we had a stack overflow because there was too much code running inside the thread ?

 

 

 

My second question is rather short: How to release thread resources if it finishes on its own ? For example:

 

static void RunThread() {

 

    int counter = 0;

 

    while(true) {

 

        counter++;

 

        if(counter > 100)

 

            break;

 

    }

 

}

 

Of course this is a simple function, but imagine a lot of memory allocation is done, how do I release the resources,

 

without being able to do a join from the main application ?

 

Thanks for any advice,

 

Janiek

TranslateQuoteReplyEditDelete

 

 

2008-06-03 11:24:57     Re: Application crash resolved after increasing pthread stack size

Mike Frysinger (UNITED STATES)

Message: 56632   

 

what you describe certainly sounds like it's in the distinct realm of possibility ... you could always enable stack checking to double check:

http://docs.blackfin.uclinux.org/doku.php?id=debuging_applications#stack_checking

 

as for your question, it depends on what resources you're talking about ... if you're talking about the internal thread structures themselves, just use pthread_detach().  otherwise, you'll have to check out the documentation to see if there's a function applicable for what you want to do.

http://www.opengroup.org/onlinepubs/009695399/basedefs/pthread.h.html

Attachments

    Outcomes