Thread: Stack underflow

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    127

    Stack underflow

    Hi, I'm trying to get some insight on what could be causing a stack underflow error. I have some code that looks like

    Code:
    void * func1(a_struct s)
    {
    
     .....
    
     printf("s = 0x%p.\n", s);
     printf("&s = 0x%p.\n", &s);
    
     foo = func2(s);
    
     .....
    
     return foo;
    }
    
    void * func2(a_struct s)
    {
     printf("s = 0x%p.\n", s);
     printf("&s = 0x%p.\n", &s);
    
     ......
    
    return foo;
    }
    func1 prints out 's' just fine but in func2 I get a stack underflow when trying to print s or &s. I can tell it's an underflow from looking at the assembly. A store instruction is getting called to store a register val just before the start of the stack. This happens with any kind of reference to 's' in func2.

    Anyone have any idea what could be going on?
    Last edited by homer_3; 09-02-2009 at 08:18 AM. Reason: typo

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stack and pointer problem
    By ramaadhitia in forum C Programming
    Replies: 2
    Last Post: 09-11-2006, 11:41 PM
  2. infix evaluation using stack
    By lewissi in forum C++ Programming
    Replies: 0
    Last Post: 11-03-2005, 02:56 AM
  3. Question about a stack using array of pointers
    By Ricochet in forum C++ Programming
    Replies: 6
    Last Post: 11-17-2003, 10:12 PM
  4. error trying to compile stack program
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-03-2003, 06:27 PM
  5. Stack Program Here
    By Troll_King in forum C Programming
    Replies: 7
    Last Post: 10-15-2001, 05:36 PM