Re: Debugging corrupted memoy



Julien Lafaye wrote:
Hello,

i callocated a pointer to a user-defined struct. The value of the pointer is
something like 0x0000002aaaaa (can't remember actually, I don't have the
computer running the code with me). Then I perform some stuff on the
allocated structure which must be buggy since after its execution the value
of the pointer is something like 0xffffff2aaaaa, i.e. same lsb, different
msb. I don't know where to start to debug this. Obviously, when I run the
programm I get a SIGSEGV when deferencing the pointer and valgrind shows no
indication of invalid memory access. Do you have any clue on how to start
debugging this. Below is the template of my code.


static int do_stuff()
{
obj_t res = *calloc((size_t)1, sizeof(obj_t));
// res is 0x000000..
obj_iterate(res);
// res is 0xffffff..
do_other_stuff(res->fied); <-- SIGSEGV
}

Julien, if this isn't the least useful problem description
I've ever seen, it must be a close second. Values are "something
like," code resembles a "template" that has no hope of compiling,
much less running, the part that you yourself think "must be buggy"
is completely concealed ...

You say "I don't know where to start debugging this," and all
I can offer based on what you've presented is "Line forty-two."

PS: my architecture is X86_64, Linux, gcc-4; code is compiled without
optimization, debugging symbols activated

That's nice. What are your hair and eye colors?

There are people here who are willing and probably able to
help you, but very few of us are mind readers. Let's see some
*actual* data (not "something like") and *actual* code (not
a "template"), and maybe we can do something. But until then ...

"Doctor, it hurts!"

"What hurts?"

"Never mind the details, just make it better!"

--
Eric Sosman
esosman@xxxxxxxxxxxxxxxxxxxx
.



Relevant Pages

  • Re: Debugging corrupted memoy
    ... i callocated a pointer to a user-defined struct. ...   // res is 0x000000.. ...   // res is 0xffffff.. ...
    (comp.lang.c)
  • Re: Debugging corrupted memoy
    ... i callocated a pointer to a user-defined struct. ... // res is 0xffffff.. ... Why the asterisk in front of calloc? ...
    (comp.lang.c)
  • Debugging corrupted memoy
    ... i callocated a pointer to a user-defined struct. ... computer running the code with me). ... // res is 0xffffff.. ...
    (comp.lang.c)
  • Re: Access Violation Debugging in Visual C++
    ... is checked against an enum. ... > my debugging skills are a bit rusty. ... your 'this' pointer in the variables window. ... member data. ...
    (microsoft.public.vc.debugger)
  • make gdb break on memory location
    ... I am debugging a program with gdb and wish to break when the ... pointer in a local procedure, and I want ... Same thing if I try "awatch &" or "awatch ... Another post by Marc Tardif discussed this same question, ...
    (comp.unix.programmer)