Re: Debugging corrupted memoy



On May 10, 11:02 pm, Julien Lafaye <sensei+use...@xxxxxxxxxxx> 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

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

Trace the value of res in obj_iterate and see where the top half
changes...

Use printf statements or perhaps a debugger.

The cause could be anything though. Some real code posted here could
help.

--
Bartc
.



Relevant Pages

  • 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: Debugging corrupted memoy
    ... i callocated a pointer to a user-defined struct. ... You say "I don't know where to start debugging this," and all ... "Doctor, it hurts!" ...
    (comp.lang.c)
  • Re: including cray pointers in fortran modules
    ...  pointer (ipt, x) ... The first layer is with the declaration of ipt and that PROGRAM ... Cray pointer at has 4 bytes of precision; ...   ...
    (comp.lang.fortran)
  • on topic to clc [Was: Banks and economy]
    ... pointer type - which I think is correct for "arrays", ... Since, as a formal parameter, char cptr[]; ... pointer to the 'completing' declaration, ...   tentative definition. ...
    (comp.lang.c)