Re: Debugging corrupted memoy
- From: jt@xxxxxxxxxxx (Jens Thoms Toerring)
- Date: 10 May 2008 21:19:17 GMT
Julien Lafaye <sensei+usenet@xxxxxxxxxxx> wrote:
The code is fundamentally wrong. You do not dereference the result of
calloc() and assign it to an object, but assign it to a pointer to the
object.
Sorry, typo in my snippet. One should read
obj_t *res = calloc((size_t)1, sizeof(obj_t));
Ok, that look more reasonable. What about other questions
like if you have included <stdlib.h> and how you did get
the value of 'res'? And what is obj_iterate() actually
doing (is it a function or a macro and why does its name
contain "iterate" when there's only one such structure)?
Finally, what is do_other_stuff() do or is it really
segfaulting already when called with 'res->fied' (what-
ever 'fied' is supposed to mean)?
If obj_iterate() is a function and the value of 'res' is
really changed after its call then I would speculate that
you're doing something nasty in obj_iterate() that some-
how writes over the place where 'res' is stored. And if
'obj_iterate' is a macro show us also what its doing.
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@xxxxxxxxxxx
\__________________________ http://toerring.de
.
- References:
- Debugging corrupted memoy
- From: Julien Lafaye
- Re: Debugging corrupted memoy
- From: Sean G. McLaughlin
- Re: Debugging corrupted memoy
- From: Julien Lafaye
- Debugging corrupted memoy
- Prev by Date: Re: Debugging corrupted memoy
- Next by Date: Re: Debugging corrupted memoy
- Previous by thread: Re: Debugging corrupted memoy
- Next by thread: Re: Debugging corrupted memoy
- Index(es):
Relevant Pages
|