> We are using “is_mem_defined” (in mc_main.) to test for “is it safe to read 
> this location?” and that does not appear to be quite right.  It looks as 
> though an address in a code segment is defined, but not readable.  We get a 
> SIGSEGV with a bad permissions message when we try.  Whether or not that is
> the correct analysis is not as important as the primary question:
>
>
>
> What is the proper way to check to see if an address is readable?  And, 
> similarly, is writable?

The *only* way to get a definitive answer is to attempt a write() from that 
address
to a temporary file.  If and only if you get no error, then the address is 
readable.

You can read and decode /proc/self/maps, but even if a page has PROT_READ
you might still get SIGBUS, such as when the page maps a hardware device
which does not respond to the particular address.


------------------------------------------------------------------------------
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to