Stack Checker - Cool!

Joel Sherrill joel.sherrill at oarcorp.com
Thu Aug 16 17:26:20 UTC 2007


Robert S. Grimes wrote:
> Figured I should test to see if it actually works!  Here's my code:
>
>   #ifdef BLOWUP_STACK
>   void blowup_stack(int numCalls) {
>     char buffer[256];
>     sprintf(buffer, "call %d", numCalls);
>     Logger::Instance().LogMessage(CLCDebug, "StackBlower: call %d,
> buffer: [%s]",
>           numCalls, buffer);
>     rtems_task_wake_after(25);
>     blowup_stack(numCalls+1);
>   }
>   #endif  // BLOWUP_STACK
>
> Simple infinite recursion - a not so beautiful thing!  It simply
> allocates a buffer, sprintf's to it, sends an Ethernet broadcast with
> the assembled messages, then recurses.  Here's the console output:
>
>   *** Master Processor - Starting Application Initialization ***
>
>  
> *****************************************************************************
>   ***  From now on, the Ethernet Logger should be the primary output
> of     ***
>   ***  these sorts of informational messages, with the sole exception
> of    ***
>   ***  ISR-level messages.  The console is hereby handed over to the
> RTEMS  ***
>   ***  Monitor and Capture
> Engine.                                          ***
>  
> ***                                                                      
> ***
>   ***  Please report any other messages to rsg at nowhere.com at your
> earliest ***
>   *** 
> convenience...                                                       ***
>  
> *****************************************************************************
>
>   Monitor ready, press enter to login.
>
>   Hit <cr> to access RTEMS Monitor facility...
>
>   BLOWN STACK!!! Offending task(0x100F38): id=0x0A010001; name=0x55493120
>     stack covers range 0x1075C0 - 0x109DC7 (10248 bytes)
>     Damaged pattern begins at 0x001075C8 and is 128 bytes long
>   rtems-4.7.99.2(PowerPC/PowerPC 405/virtex) PANIC ERROR 81
>   system stopped, press RESET
>
> And here are the Ethernet messages:
>
>   12:38:14 PM : *** Master Processor, Reporting for Doodie! ***
>   12:38:21 PM : StackBlower: call 1, buffer: [call 1]
>   12:38:21 PM : StackBlower: call 2, buffer: [call 2]
>     <snip>
>   12:38:27 PM : StackBlower: call 26, buffer: [call 26]
>   12:38:28 PM : StackBlower: call 27, buffer: [call 27]
>
>
> Oh, what a beautiful thing!  (Of course, I hope I never see that
> printout again!!!)
>   

To make sure everyone understands, the stack checker
only runs automatically as part of a context switch.

You can call rtems_stack_checker_is_blown() at
any time to check yourself.  It just returns a boolean.

If someone ever gets VERY VERY desperate, I recently
added some conditionals which can turn on walking
the heap and checking the stack EVERY time you
enter an RTEMS dispatching disabled critical section.
You have to recompile but since this is such a heavy
handed thing to have on, that seemed a fair trade off.

I really need to mention that in the class this time
since it is new. :)
> Thanks, Joel!
>   

Your welcome.  We need to make sure Thomas gets
to review this but I think the linkcmds is just broken
for the way memory is allocated.
> -Bob
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.com
> http://rtems.rtems.org/mailman/listinfo/rtems-users
>   




More information about the users mailing list