Question

I'm trying to track down a segfault in a c++ program. I noticed that argc has been modified to a very large number at the time of the segfault. The number happens to be an address in the address space of my application. This led me to believe that something is corrupting my main stack frame. The question is, how do I get the address on the stack which points to argc, so that I can tell what method is modifying the argument in my program? I want to step through the program and watch that address space for changes. This segfault is happening on hpux and aix (right now I'm looking at hpux). I've been looking through the stack, but I can't find my argc variable pushed anywhere onto the stack. I'm debugging with gdb.

Does anyone know where argc would be stored on the stack frame of an hpux pa-risc machine?

Was it helpful?

Solution

Apparently hpux pa-risc stores argc in a register, not in memory (which gdb informed me when I did p &argc). argc only changed because hpux pa-risc reassigned the the register because it wasn't being used. On linux, argc is stored on the stack.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top