Stack Checker - Cool!

Robert S. Grimes rsg at alum.mit.edu
Thu Aug 16 16:47:07 UTC 2007


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!!!)

Thanks, Joel!
-Bob



More information about the users mailing list