Search the web
Sign In
New User? Sign Up
dmalloc · Debug Malloc Library (dmalloc) Group
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
spurious "not pointing to heap data space" error?   Message List  
Reply | Forward Message #361 of 529 |

I'm using dmalloc 4.8.2 on Mandrake 8.1 to debug a small C library I'm
writing (the library fakes large files on systems that don't have them). In
addition to the library itself, I'm writing a Python binding. My C test
program runs without complaint, but the Python test script generates a
"pointer is not pointing to heap data space" error, which I think is
spurious. This error occurs in the close function, where all the little
fiddly bits get freed. At the top of the close function The struct looks
like this in gdb:

$36 = {
mode = 0x821da48 "w",
pad1 = 0x0,
pad2 = 0x0,
path = 0x8222b98 "foo1",
pad3 = 0x0,
pad4 = 0x0,
position = 4020,
length = 4020,
basedir = 0x8248348,
current = 0x8173468,
nchunks = 2,
current_chunk = 1,
chunks = 0x8251108
}

(Note the four pad fields. They are just fences around the path field.)
The close function looks like

static int
_alf_close (ALF *stream)
{
int i,n;

n = fclose(stream->current);
stream->current = NULL;

for (i=0;i<stream->nchunks;i++)
free(stream->chunks[i].path);
free(stream->chunks);
stream->chunks = NULL;

n = n || closedir(stream->basedir);
stream->basedir = NULL;

free(stream->path);
stream->path = NULL;

free(stream->mode);
stream->mode = NULL;

return n;
}

When an attempt is made to free stream->path, dmalloc emits the non-heap
pointer error. However, it seems to me the pointer is within range. (It
was allocated by a call to strdup.) The basedir, current, and chunks fields
have all successfully been freed and set to NULL by the time the path field
itself is freed:

$37 = {
mode = 0x821da48 "w",
pad1 = 0x0,
pad2 = 0x0,
path = 0x8222b98 "foo1",
pad3 = 0x0,
pad4 = 0x0,
position = 4020,
length = 4020,
basedir = 0x0,
current = 0x0,
nchunks = 2,
current_chunk = 1,
chunks = 0x0
}

I'm running dmalloc with the following settings:

log-stats, log-non-free, log-trans, log-admin, check-fence, check-funcs,
check-heap, check-lists, realloc-copy, free-blank, error-abort,
alloc-blank

Python itself was not built with dmalloc, but the C code that went into
making the library available to Python was (the library itself and the
wrapper code that exposes the library to Python).

Any idea what might be going on?

Thx,

--
Skip Montanaro (skip@... - http://www.mojam.com/)



Tue Feb 12, 2002 6:52 pm

smontanaro
Offline Offline
Send Email Send Email

Forward
Message #361 of 529 |
Expand Messages Author Sort by Date

I'm using dmalloc 4.8.2 on Mandrake 8.1 to debug a small C library I'm writing (the library fakes large files on systems that don't have them). In addition to...
Skip Montanaro
smontanaro
Offline Send Email
Feb 12, 2002
6:51 pm

... Hrmm. It does look like it should be fine. The only way for the ERROR_NOT_IN_HEAP (21) is generated if the pointer is out-of-bounds of the range set by...
Gray Watson
graywatson1
Offline Send Email
Feb 12, 2002
10:51 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help