Hi Coders,

Do any of you have experience with the mincore(2) system call?
Allegedly it can be used to determine whether pages are resident in
memory.

Apparently, on some of the BSDs it is buggy.

But my most recent question, discovered while making sure the next
release of libexplain builds on ia64, is this:

Is there any particular reason why ia64 (but not 32-bit) version of
Linux mincore would return "not mapped" for stack segments?

My fall-back way for discovering if some memory is not mapped is to call
lstat using the pointer as the pathname argument, and seeing if EFAULT
comes back.  This has problems tho, e.g. if the pointer looks like an
unterminated string and it looks at too much memory before barfing.
Is there a devious better-except-for-mincore way of doing this?

(preferably without perturbing the process state, like opening file
descriptors so we can write memory pages to /dev/null, or mlock and then
munlock pages)

Interestingly mincore(2) on ia64 Dapper (2.6.15) says "ENOMEM address to
address + length contained unmapped memory, or memory not part of a
file."  (the stack definitely is not part of a file)
While mincore(2) on 32-bit Jaunty (2.6.29) says "ENOMEM addr to addr +
length contained unmapped memory."
This makes me think the mincore function is even more os-specific than I
thought.


-- 
Regards
Peter Miller <[email protected]>
/\/\*        http://miller.emu.id.au/pmiller/

PGP public key ID: 1024D/D0EDB64D
fingerprint = AD0A C5DF C426 4F03 5D53  2BDB 18D8 A4E2 D0ED B64D
See http://www.keyserver.net or any PGP keyserver for public key.

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
coders mailing list
[email protected]
http://lists.slug.org.au/listinfo/coders

Reply via email to