mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-03 10:05:29 +00:00
Terminology change: previously in Memcheck we had the four states:
noaccess, writable, readable, other
Now they are:
noaccess, undefined, defined, partdefined
As a result, the following names:
make_writable, make_readable,
check_writable, check_readable, check_defined
have become:
make_mem_undefined, make_mem_defined,
check_mem_is_addressable, check_mem_is_defined, check_value_is_defined
(and likewise for the upper-case versions for client request macros).
The old MAKE_* and CHECK_* macros still work for backwards compatibility.
This is much better, because the old names were subtly misleading. For
example:
- "readable" really meant "readable and writable".
- "writable" really meant "writable and maybe readable, depending on how
the read value is used".
- "check_writable" really meant "check writable or readable"
The new names avoid these problems.
The recently-added macro which was called MAKE_DEFINED is now
MAKE_MEM_DEFINED_IF_ADDRESSABLE.
I also corrected the spelling of "addressable" in numerous places in
memcheck.h.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5802
This commit is contained in:
parent
c4cde48b67
commit
3d12e0e9db
24
NEWS
24
NEWS
@ -28,6 +28,30 @@ In detail:
|
||||
|
||||
- XXX: others...
|
||||
|
||||
Other user-visible changes:
|
||||
|
||||
- There are some changes to Memcheck's client requests. Some of them have
|
||||
changed names:
|
||||
|
||||
MAKE_NOACCESS --> MAKE_MEM_NOACCESS
|
||||
MAKE_WRITABLE --> MAKE_MEM_UNDEFINED
|
||||
MAKE_READABLE --> MAKE_MEM_DEFINED
|
||||
|
||||
CHECK_WRITABLE --> CHECK_MEM_IS_ADDRESSABLE
|
||||
CHECK_READABLE --> CHECK_MEM_IS_DEFINED
|
||||
CHECK_DEFINED --> CHECK_VALUE_IS_DEFINED
|
||||
|
||||
The reason for the change is that the old names are subtly misleading.
|
||||
The old names will still work, but they are deprecated and may be removed
|
||||
in a future release.
|
||||
|
||||
We also added a new client request:
|
||||
|
||||
MAKE_MEM_DEFINED_IF_ADDRESSABLE(a, len)
|
||||
|
||||
which is like MAKE_MEM_DEFINED but only affects a byte if the byte is
|
||||
already addressable.
|
||||
|
||||
BUGS FIXED:
|
||||
|
||||
XXX
|
||||
|
||||
@ -685,35 +685,35 @@ void mpiwrap_walk_type_EXTERNALLY_VISIBLE
|
||||
*/
|
||||
|
||||
static inline
|
||||
void check_readable_untyped ( void* buffer, long nbytes )
|
||||
void check_mem_is_defined_untyped ( void* buffer, long nbytes )
|
||||
{
|
||||
if (nbytes > 0) {
|
||||
VALGRIND_CHECK_READABLE(buffer, nbytes);
|
||||
VALGRIND_CHECK_MEM_IS_DEFINED(buffer, nbytes);
|
||||
}
|
||||
}
|
||||
|
||||
static inline
|
||||
void check_writable_untyped ( void* buffer, long nbytes )
|
||||
void check_mem_is_addressable_untyped ( void* buffer, long nbytes )
|
||||
{
|
||||
if (nbytes > 0) {
|
||||
VALGRIND_CHECK_WRITABLE(buffer, nbytes);
|
||||
VALGRIND_CHECK_MEM_IS_ADDRESSABLE(buffer, nbytes);
|
||||
}
|
||||
}
|
||||
|
||||
static inline
|
||||
void make_defined_untyped ( void* buffer, long nbytes )
|
||||
void make_mem_defined_if_addressable_untyped ( void* buffer, long nbytes )
|
||||
{
|
||||
if (nbytes > 0) {
|
||||
VALGRIND_MAKE_DEFINED(buffer, nbytes);
|
||||
VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(buffer, nbytes);
|
||||
}
|
||||
}
|
||||
|
||||
static inline
|
||||
void make_defined_if_success_untyped ( int err,
|
||||
void make_mem_defined_if_addressable_if_success_untyped ( int err,
|
||||
void* buffer, long nbytes )
|
||||
{
|
||||
if (err == MPI_SUCCESS && nbytes > 0) {
|
||||
VALGRIND_MAKE_DEFINED(buffer, nbytes);
|
||||
VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(buffer, nbytes);
|
||||
}
|
||||
}
|
||||
|
||||
@ -721,10 +721,10 @@ void make_defined_if_success_untyped ( int err,
|
||||
(safe-to-write) state. */
|
||||
|
||||
static inline
|
||||
void make_writable_untyped ( void* buffer, long nbytes )
|
||||
void make_mem_undefined_untyped ( void* buffer, long nbytes )
|
||||
{
|
||||
if (nbytes > 0) {
|
||||
VALGRIND_MAKE_WRITABLE(buffer, nbytes);
|
||||
VALGRIND_MAKE_MEM_UNDEFINED(buffer, nbytes);
|
||||
}
|
||||
}
|
||||
|
||||
@ -739,9 +739,9 @@ void make_writable_untyped ( void* buffer, long nbytes )
|
||||
initialised data, and cause V to complain if not. */
|
||||
|
||||
static
|
||||
void check_readable ( char* buffer, long count, MPI_Datatype datatype )
|
||||
void check_mem_is_defined ( char* buffer, long count, MPI_Datatype datatype )
|
||||
{
|
||||
walk_type_array( check_readable_untyped, buffer, datatype, count );
|
||||
walk_type_array( check_mem_is_defined_untyped, buffer, datatype, count );
|
||||
}
|
||||
|
||||
|
||||
@ -750,9 +750,9 @@ void check_readable ( char* buffer, long count, MPI_Datatype datatype )
|
||||
initialised or not. */
|
||||
|
||||
static
|
||||
void check_writable ( void *buffer, long count, MPI_Datatype datatype )
|
||||
void check_mem_is_addressable ( void *buffer, long count, MPI_Datatype datatype )
|
||||
{
|
||||
walk_type_array( check_writable_untyped, buffer, datatype, count );
|
||||
walk_type_array( check_mem_is_addressable_untyped, buffer, datatype, count );
|
||||
}
|
||||
|
||||
|
||||
@ -760,18 +760,19 @@ void check_writable ( void *buffer, long count, MPI_Datatype datatype )
|
||||
addressible' state. */
|
||||
|
||||
static
|
||||
void make_defined ( void *buffer, int count, MPI_Datatype datatype )
|
||||
void make_mem_defined_if_addressable ( void *buffer, int count, MPI_Datatype datatype )
|
||||
{
|
||||
walk_type_array( make_defined_untyped, buffer, datatype, count );
|
||||
walk_type_array( make_mem_defined_if_addressable_untyped,
|
||||
buffer, datatype, count );
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
make_defined_if_success ( int err, void *buffer, int count,
|
||||
MPI_Datatype datatype )
|
||||
make_mem_defined_if_addressable_if_success ( int err, void *buffer, int count,
|
||||
MPI_Datatype datatype )
|
||||
{
|
||||
if (err == MPI_SUCCESS)
|
||||
make_defined(buffer, count, datatype);
|
||||
make_mem_defined_if_addressable(buffer, count, datatype);
|
||||
}
|
||||
|
||||
|
||||
@ -812,7 +813,7 @@ int generic_Send(void *buf, int count, MPI_Datatype datatype,
|
||||
int err;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("{,B,S,R}Send");
|
||||
check_readable(buf, count, datatype);
|
||||
check_mem_is_defined(buf, count, datatype);
|
||||
CALL_FN_W_6W(err, fn, buf,count,datatype,dest,tag,comm);
|
||||
after("{,B,S,R}Send", err);
|
||||
return err;
|
||||
@ -848,11 +849,11 @@ int WRAPPER_FOR(PMPI_Recv)(void *buf, int count, MPI_Datatype datatype,
|
||||
int err, recv_count = 0;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Recv");
|
||||
check_writable(buf, count, datatype);
|
||||
check_writable_untyped(status, sizeof(*status));
|
||||
check_mem_is_addressable(buf, count, datatype);
|
||||
check_mem_is_addressable_untyped(status, sizeof(*status));
|
||||
CALL_FN_W_7W(err, fn, buf,count,datatype,source,tag,comm,status);
|
||||
if (err == MPI_SUCCESS && count_from_Status(&recv_count,datatype,status)) {
|
||||
make_defined(buf, recv_count, datatype);
|
||||
make_mem_defined_if_addressable(buf, recv_count, datatype);
|
||||
}
|
||||
after("Recv", err);
|
||||
return err;
|
||||
@ -869,7 +870,7 @@ int WRAPPER_FOR(PMPI_Get_count)(MPI_Status* status,
|
||||
int err;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Get_count");
|
||||
check_readable_untyped(status, sizeof(*status));
|
||||
check_mem_is_defined_untyped(status, sizeof(*status));
|
||||
CALL_FN_W_WWW(err, fn, status,ty,count);
|
||||
after("Get_count", err);
|
||||
return err;
|
||||
@ -1095,7 +1096,7 @@ static void maybe_complete ( Bool error_in_status,
|
||||
/* The Irecv detailed in 'shadow' completed. Paint the result
|
||||
buffer, and delete the entry. */
|
||||
if (count_from_Status(&recv_count, shadow->datatype, status)) {
|
||||
make_defined(shadow->buf, recv_count, shadow->datatype);
|
||||
make_mem_defined_if_addressable(shadow->buf, recv_count, shadow->datatype);
|
||||
if (opt_verbosity > 1)
|
||||
fprintf(stderr, "%s %5d: sReq- %p (completed)\n",
|
||||
preamble, my_pid, request_before);
|
||||
@ -1117,10 +1118,10 @@ int generic_Isend(void *buf, int count, MPI_Datatype datatype,
|
||||
int err;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("{,B,S,R}Isend");
|
||||
check_readable(buf, count, datatype);
|
||||
check_writable_untyped(request, sizeof(*request));
|
||||
check_mem_is_defined(buf, count, datatype);
|
||||
check_mem_is_addressable_untyped(request, sizeof(*request));
|
||||
CALL_FN_W_7W(err, fn, buf,count,datatype,dest,tag,comm,request);
|
||||
make_defined_if_success_untyped(err, request, sizeof(*request));
|
||||
make_mem_defined_if_addressable_if_success_untyped(err, request, sizeof(*request));
|
||||
after("{,B,S,R}Isend", err);
|
||||
return err;
|
||||
}
|
||||
@ -1160,11 +1161,11 @@ int WRAPPER_FOR(PMPI_Irecv)( void* buf, int count, MPI_Datatype datatype,
|
||||
int err;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Irecv");
|
||||
check_writable(buf, count, datatype);
|
||||
check_writable_untyped(request, sizeof(*request));
|
||||
check_mem_is_addressable(buf, count, datatype);
|
||||
check_mem_is_addressable_untyped(request, sizeof(*request));
|
||||
CALL_FN_W_7W(err, fn, buf,count,datatype,source,tag,comm,request);
|
||||
if (err == MPI_SUCCESS) {
|
||||
make_defined_untyped(request, sizeof(*request));
|
||||
make_mem_defined_if_addressable_untyped(request, sizeof(*request));
|
||||
add_shadow_Request( *request, buf,count,datatype );
|
||||
}
|
||||
after("Irecv", err);
|
||||
@ -1185,14 +1186,14 @@ int WRAPPER_FOR(PMPI_Wait)( MPI_Request* request,
|
||||
int err;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Wait");
|
||||
check_writable_untyped(status, sizeof(MPI_Status));
|
||||
check_readable_untyped(request, sizeof(MPI_Request));
|
||||
check_mem_is_addressable_untyped(status, sizeof(MPI_Status));
|
||||
check_mem_is_defined_untyped(request, sizeof(MPI_Request));
|
||||
request_before = *request;
|
||||
CALL_FN_W_WW(err, fn, request,status);
|
||||
if (err == MPI_SUCCESS) {
|
||||
maybe_complete(False/*err in status?*/,
|
||||
request_before, *request, status);
|
||||
make_defined_untyped(status, sizeof(MPI_Status));
|
||||
make_mem_defined_if_addressable_untyped(status, sizeof(MPI_Status));
|
||||
}
|
||||
after("Wait", err);
|
||||
return err;
|
||||
@ -1210,8 +1211,8 @@ int WRAPPER_FOR(PMPI_Waitall)( int count,
|
||||
before("Waitall");
|
||||
if (0) fprintf(stderr, "Waitall: %d\n", count);
|
||||
for (i = 0; i < count; i++) {
|
||||
check_writable_untyped(&statuses[i], sizeof(MPI_Status));
|
||||
check_readable_untyped(&requests[i], sizeof(MPI_Request));
|
||||
check_mem_is_addressable_untyped(&statuses[i], sizeof(MPI_Status));
|
||||
check_mem_is_defined_untyped(&requests[i], sizeof(MPI_Request));
|
||||
}
|
||||
requests_before = clone_Request_array( count, requests );
|
||||
CALL_FN_W_WWW(err, fn, count,requests,statuses);
|
||||
@ -1221,7 +1222,8 @@ int WRAPPER_FOR(PMPI_Waitall)( int count,
|
||||
for (i = 0; i < count; i++) {
|
||||
maybe_complete(e_i_s, requests_before[i], requests[i],
|
||||
&statuses[i]);
|
||||
make_defined_untyped(&statuses[i], sizeof(MPI_Status));
|
||||
make_mem_defined_if_addressable_untyped(&statuses[i],
|
||||
sizeof(MPI_Status));
|
||||
}
|
||||
}
|
||||
if (requests_before)
|
||||
@ -1240,15 +1242,15 @@ int WRAPPER_FOR(PMPI_Test)( MPI_Request* request, int* flag,
|
||||
int err;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Test");
|
||||
check_writable_untyped(status, sizeof(MPI_Status));
|
||||
check_writable_untyped(flag, sizeof(int));
|
||||
check_readable_untyped(request, sizeof(MPI_Request));
|
||||
check_mem_is_addressable_untyped(status, sizeof(MPI_Status));
|
||||
check_mem_is_addressable_untyped(flag, sizeof(int));
|
||||
check_mem_is_defined_untyped(request, sizeof(MPI_Request));
|
||||
request_before = *request;
|
||||
CALL_FN_W_WWW(err, fn, request,flag,status);
|
||||
if (err == MPI_SUCCESS && *flag) {
|
||||
maybe_complete(False/*err in status?*/,
|
||||
request_before, *request, status);
|
||||
make_defined_untyped(status, sizeof(MPI_Status));
|
||||
make_mem_defined_if_addressable_untyped(status, sizeof(MPI_Status));
|
||||
}
|
||||
after("Test", err);
|
||||
return err;
|
||||
@ -1265,10 +1267,10 @@ int WRAPPER_FOR(PMPI_Testall)( int count, MPI_Request* requests,
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Testall");
|
||||
if (0) fprintf(stderr, "Testall: %d\n", count);
|
||||
check_writable_untyped(flag, sizeof(int));
|
||||
check_mem_is_addressable_untyped(flag, sizeof(int));
|
||||
for (i = 0; i < count; i++) {
|
||||
check_writable_untyped(&statuses[i], sizeof(MPI_Status));
|
||||
check_readable_untyped(&requests[i], sizeof(MPI_Request));
|
||||
check_mem_is_addressable_untyped(&statuses[i], sizeof(MPI_Status));
|
||||
check_mem_is_defined_untyped(&requests[i], sizeof(MPI_Request));
|
||||
}
|
||||
requests_before = clone_Request_array( count, requests );
|
||||
CALL_FN_W_WWWW(err, fn, count,requests,flag,statuses);
|
||||
@ -1280,7 +1282,7 @@ int WRAPPER_FOR(PMPI_Testall)( int count, MPI_Request* requests,
|
||||
for (i = 0; i < count; i++) {
|
||||
maybe_complete(e_i_s, requests_before[i], requests[i],
|
||||
&statuses[i]);
|
||||
make_defined_untyped(&statuses[i], sizeof(MPI_Status));
|
||||
make_mem_defined_if_addressable_untyped(&statuses[i], sizeof(MPI_Status));
|
||||
}
|
||||
}
|
||||
if (requests_before)
|
||||
@ -1301,13 +1303,13 @@ int WRAPPER_FOR(PMPI_Iprobe)(int source, int tag,
|
||||
int err;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Iprobe");
|
||||
check_writable_untyped(flag, sizeof(*flag));
|
||||
check_writable_untyped(status, sizeof(*status));
|
||||
check_mem_is_addressable_untyped(flag, sizeof(*flag));
|
||||
check_mem_is_addressable_untyped(status, sizeof(*status));
|
||||
CALL_FN_W_5W(err, fn, source,tag,comm,flag,status);
|
||||
if (err == MPI_SUCCESS) {
|
||||
make_defined_untyped(flag, sizeof(*flag));
|
||||
make_mem_defined_if_addressable_untyped(flag, sizeof(*flag));
|
||||
if (*flag)
|
||||
make_defined_untyped(status, sizeof(*status));
|
||||
make_mem_defined_if_addressable_untyped(status, sizeof(*status));
|
||||
}
|
||||
after("Iprobe", err);
|
||||
return err;
|
||||
@ -1323,9 +1325,9 @@ int WRAPPER_FOR(PMPI_Probe)(int source, int tag,
|
||||
int err;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Probe");
|
||||
check_writable_untyped(status, sizeof(*status));
|
||||
check_mem_is_addressable_untyped(status, sizeof(*status));
|
||||
CALL_FN_W_WWWW(err, fn, source,tag,comm,status);
|
||||
make_defined_if_success_untyped(err, status, sizeof(*status));
|
||||
make_mem_defined_if_addressable_if_success_untyped(err, status, sizeof(*status));
|
||||
after("Probe", err);
|
||||
return err;
|
||||
}
|
||||
@ -1341,7 +1343,7 @@ int WRAPPER_FOR(PMPI_Cancel)(MPI_Request* request)
|
||||
MPI_Request tmp;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Cancel");
|
||||
check_writable_untyped(request, sizeof(*request));
|
||||
check_mem_is_addressable_untyped(request, sizeof(*request));
|
||||
tmp = *request;
|
||||
CALL_FN_W_W(err, fn, request);
|
||||
if (err == MPI_SUCCESS)
|
||||
@ -1374,14 +1376,14 @@ int WRAPPER_FOR(PMPI_Sendrecv)(
|
||||
int err, recvcount_actual = 0;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Sendrecv");
|
||||
check_readable(sendbuf, sendcount, sendtype);
|
||||
check_writable(recvbuf, recvcount, recvtype);
|
||||
check_mem_is_defined(sendbuf, sendcount, sendtype);
|
||||
check_mem_is_addressable(recvbuf, recvcount, recvtype);
|
||||
CALL_FN_W_12W(err, fn, sendbuf,sendcount,sendtype,dest,sendtag,
|
||||
recvbuf,recvcount,recvtype,source,recvtag,
|
||||
comm,status);
|
||||
if (err == MPI_SUCCESS
|
||||
&& count_from_Status(&recvcount_actual,recvtype,status)) {
|
||||
make_defined(recvbuf, recvcount_actual, recvtype);
|
||||
make_mem_defined_if_addressable(recvbuf, recvcount_actual, recvtype);
|
||||
}
|
||||
after("Sendrecv", err);
|
||||
return err;
|
||||
@ -1414,7 +1416,7 @@ int WRAPPER_FOR(PMPI_Type_commit)( MPI_Datatype* ty )
|
||||
int err;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Type_commit");
|
||||
check_readable_untyped(ty, sizeof(*ty));
|
||||
check_mem_is_defined_untyped(ty, sizeof(*ty));
|
||||
CALL_FN_W_W(err, fn, ty);
|
||||
after("Type_commit", err);
|
||||
return err;
|
||||
@ -1427,7 +1429,7 @@ int WRAPPER_FOR(PMPI_Type_free)( MPI_Datatype* ty )
|
||||
int err;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Type_free");
|
||||
check_readable_untyped(ty, sizeof(*ty));
|
||||
check_mem_is_defined_untyped(ty, sizeof(*ty));
|
||||
CALL_FN_W_W(err, fn, ty);
|
||||
after("Type_free", err);
|
||||
return err;
|
||||
@ -1460,12 +1462,12 @@ int WRAPPER_FOR(PMPI_Bcast)(void *buffer, int count,
|
||||
before("Bcast");
|
||||
i_am_sender = root == comm_rank(comm);
|
||||
if (i_am_sender) {
|
||||
check_readable(buffer, count, datatype);
|
||||
check_mem_is_defined(buffer, count, datatype);
|
||||
} else {
|
||||
check_writable(buffer, count, datatype);
|
||||
check_mem_is_addressable(buffer, count, datatype);
|
||||
}
|
||||
CALL_FN_W_5W(err, fn, buffer,count,datatype,root,comm);
|
||||
make_defined_if_success(err, buffer, count, datatype);
|
||||
make_mem_defined_if_addressable_if_success(err, buffer, count, datatype);
|
||||
after("Bcast", err);
|
||||
return err;
|
||||
}
|
||||
@ -1500,14 +1502,14 @@ int WRAPPER_FOR(PMPI_Gather)(
|
||||
before("Gather");
|
||||
me = comm_rank(comm);
|
||||
sz = comm_size(comm);
|
||||
check_readable(sendbuf, sendcount, sendtype);
|
||||
check_mem_is_defined(sendbuf, sendcount, sendtype);
|
||||
if (me == root)
|
||||
check_writable(recvbuf, recvcount * sz, recvtype);
|
||||
check_mem_is_addressable(recvbuf, recvcount * sz, recvtype);
|
||||
CALL_FN_W_8W(err, fn, sendbuf,sendcount,sendtype,
|
||||
recvbuf,recvcount,recvtype,
|
||||
root,comm);
|
||||
if (me == root)
|
||||
make_defined_if_success(err, recvbuf, recvcount * sz, recvtype);
|
||||
make_mem_defined_if_addressable_if_success(err, recvbuf, recvcount * sz, recvtype);
|
||||
after("Gather", err);
|
||||
return err;
|
||||
}
|
||||
@ -1534,13 +1536,13 @@ int WRAPPER_FOR(PMPI_Scatter)(
|
||||
before("Scatter");
|
||||
me = comm_rank(comm);
|
||||
sz = comm_size(comm);
|
||||
check_writable(recvbuf, recvcount, recvtype);
|
||||
check_mem_is_addressable(recvbuf, recvcount, recvtype);
|
||||
if (me == root)
|
||||
check_readable(sendbuf, sendcount * sz, sendtype);
|
||||
check_mem_is_defined(sendbuf, sendcount * sz, sendtype);
|
||||
CALL_FN_W_8W(err, fn, sendbuf,sendcount,sendtype,
|
||||
recvbuf,recvcount,recvtype,
|
||||
root,comm);
|
||||
make_defined_if_success(err, recvbuf, recvcount, recvtype);
|
||||
make_mem_defined_if_addressable_if_success(err, recvbuf, recvcount, recvtype);
|
||||
after("Scatter", err);
|
||||
return err;
|
||||
}
|
||||
@ -1566,12 +1568,12 @@ int WRAPPER_FOR(PMPI_Alltoall)(
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Alltoall");
|
||||
sz = comm_size(comm);
|
||||
check_readable(sendbuf, sendcount * sz, sendtype);
|
||||
check_writable(recvbuf, recvcount * sz, recvtype);
|
||||
check_mem_is_defined(sendbuf, sendcount * sz, sendtype);
|
||||
check_mem_is_addressable(recvbuf, recvcount * sz, recvtype);
|
||||
CALL_FN_W_7W(err, fn, sendbuf,sendcount,sendtype,
|
||||
recvbuf,recvcount,recvtype,
|
||||
comm);
|
||||
make_defined_if_success(err, recvbuf, recvcount * sz, recvtype);
|
||||
make_mem_defined_if_addressable_if_success(err, recvbuf, recvcount * sz, recvtype);
|
||||
after("Alltoall", err);
|
||||
return err;
|
||||
}
|
||||
@ -1598,12 +1600,12 @@ int WRAPPER_FOR(PMPI_Reduce)(void *sendbuf, void *recvbuf,
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Reduce");
|
||||
i_am_root = root == comm_rank(comm);
|
||||
check_readable(sendbuf, count, datatype);
|
||||
check_mem_is_defined(sendbuf, count, datatype);
|
||||
if (i_am_root)
|
||||
check_writable(recvbuf, count, datatype);
|
||||
check_mem_is_addressable(recvbuf, count, datatype);
|
||||
CALL_FN_W_7W(err, fn, sendbuf,recvbuf,count,datatype,op,root,comm);
|
||||
if (i_am_root)
|
||||
make_defined_if_success(err, recvbuf, count, datatype);
|
||||
make_mem_defined_if_addressable_if_success(err, recvbuf, count, datatype);
|
||||
after("Reduce", err);
|
||||
return err;
|
||||
}
|
||||
@ -1622,10 +1624,10 @@ int WRAPPER_FOR(PMPI_Allreduce)(void *sendbuf, void *recvbuf,
|
||||
int err;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Allreduce");
|
||||
check_readable(sendbuf, count, datatype);
|
||||
check_writable(recvbuf, count, datatype);
|
||||
check_mem_is_defined(sendbuf, count, datatype);
|
||||
check_mem_is_addressable(recvbuf, count, datatype);
|
||||
CALL_FN_W_6W(err, fn, sendbuf,recvbuf,count,datatype,op,comm);
|
||||
make_defined_if_success(err, recvbuf, count, datatype);
|
||||
make_mem_defined_if_addressable_if_success(err, recvbuf, count, datatype);
|
||||
after("Allreduce", err);
|
||||
return err;
|
||||
}
|
||||
@ -1643,9 +1645,9 @@ int WRAPPER_FOR(PMPI_Op_create)( MPI_User_function* function,
|
||||
int err;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Op_create");
|
||||
check_writable_untyped(op, sizeof(*op));
|
||||
check_mem_is_addressable_untyped(op, sizeof(*op));
|
||||
CALL_FN_W_WWW(err, fn, function,commute,op);
|
||||
make_defined_if_success_untyped(err, op, sizeof(*op));
|
||||
make_mem_defined_if_addressable_if_success_untyped(err, op, sizeof(*op));
|
||||
after("Op_create", err);
|
||||
return err;
|
||||
}
|
||||
@ -1708,9 +1710,9 @@ int WRAPPER_FOR(PMPI_Comm_rank)(MPI_Comm comm, int *rank)
|
||||
int err;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Comm_rank");
|
||||
check_writable_untyped(rank, sizeof(*rank));
|
||||
check_mem_is_addressable_untyped(rank, sizeof(*rank));
|
||||
CALL_FN_W_WW(err, fn, comm,rank);
|
||||
make_defined_if_success_untyped(err, rank, sizeof(*rank));
|
||||
make_mem_defined_if_addressable_if_success_untyped(err, rank, sizeof(*rank));
|
||||
after("Comm_rank", err);
|
||||
return err;
|
||||
}
|
||||
@ -1723,9 +1725,9 @@ int WRAPPER_FOR(PMPI_Comm_size)(MPI_Comm comm, int *size)
|
||||
int err;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Comm_size");
|
||||
check_writable_untyped(size, sizeof(*size));
|
||||
check_mem_is_addressable_untyped(size, sizeof(*size));
|
||||
CALL_FN_W_WW(err, fn, comm,size);
|
||||
make_defined_if_success_untyped(err, size, sizeof(*size));
|
||||
make_mem_defined_if_addressable_if_success_untyped(err, size, sizeof(*size));
|
||||
after("Comm_size", err);
|
||||
return err;
|
||||
}
|
||||
@ -1752,8 +1754,8 @@ int WRAPPER_FOR(PMPI_Error_string)( int errorcode, char* string,
|
||||
int err;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Error_string");
|
||||
check_writable_untyped(resultlen, sizeof(int));
|
||||
check_writable_untyped(string, MPI_MAX_ERROR_STRING);
|
||||
check_mem_is_addressable_untyped(resultlen, sizeof(int));
|
||||
check_mem_is_addressable_untyped(string, MPI_MAX_ERROR_STRING);
|
||||
CALL_FN_W_WWW(err, fn, errorcode,string,resultlen);
|
||||
/* Don't bother to paint the result; we assume the real function
|
||||
will have filled it with defined characters :-) */
|
||||
@ -1776,8 +1778,8 @@ int WRAPPER_FOR(PMPI_Init)(int *argc, char ***argv)
|
||||
int err;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Init");
|
||||
check_readable_untyped(argc, sizeof(int));
|
||||
check_readable_untyped(*argv, *argc * sizeof(char**));
|
||||
check_mem_is_defined_untyped(argc, sizeof(int));
|
||||
check_mem_is_defined_untyped(*argv, *argc * sizeof(char**));
|
||||
CALL_FN_W_WW(err, fn, argc,argv);
|
||||
after("Init", err);
|
||||
return err;
|
||||
@ -1790,9 +1792,9 @@ int WRAPPER_FOR(PMPI_Initialized)(int* flag)
|
||||
int err;
|
||||
VALGRIND_GET_ORIG_FN(fn);
|
||||
before("Initialized");
|
||||
check_writable_untyped(flag, sizeof(int));
|
||||
check_mem_is_addressable_untyped(flag, sizeof(int));
|
||||
CALL_FN_W_W(err, fn, flag);
|
||||
make_defined_if_success_untyped(err, flag, sizeof(int));
|
||||
make_mem_defined_if_addressable_if_success_untyped(err, flag, sizeof(int));
|
||||
after("Initialized", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
@ -580,7 +580,7 @@ Superblock* newSuperblock ( Arena* a, SizeT cszB )
|
||||
}
|
||||
}
|
||||
vg_assert(NULL != sb);
|
||||
//zzVALGRIND_MAKE_WRITABLE(sb, cszB);
|
||||
//zzVALGRIND_MAKE_MEM_UNDEFINED(sb, cszB);
|
||||
vg_assert(0 == (Addr)sb % VG_MIN_MALLOC_SZB);
|
||||
sb->n_payload_bytes = cszB - sizeof(Superblock);
|
||||
a->bytes_mmaped += cszB;
|
||||
@ -914,7 +914,7 @@ void mkFreeBlock ( Arena* a, Block* b, SizeT bszB, UInt b_lno )
|
||||
{
|
||||
SizeT pszB = bszB_to_pszB(a, bszB);
|
||||
vg_assert(b_lno == pszB_to_listNo(pszB));
|
||||
//zzVALGRIND_MAKE_WRITABLE(b, bszB);
|
||||
//zzVALGRIND_MAKE_MEM_UNDEFINED(b, bszB);
|
||||
// Set the size fields and indicate not-in-use.
|
||||
set_bszB(b, mk_free_bszB(bszB));
|
||||
|
||||
@ -943,7 +943,7 @@ void mkInuseBlock ( Arena* a, Block* b, SizeT bszB )
|
||||
{
|
||||
UInt i;
|
||||
vg_assert(bszB >= min_useful_bszB(a));
|
||||
//zzVALGRIND_MAKE_WRITABLE(b, bszB);
|
||||
//zzVALGRIND_MAKE_MEM_UNDEFINED(b, bszB);
|
||||
set_bszB(b, mk_inuse_bszB(bszB));
|
||||
set_prev_b(b, NULL); // Take off freelist
|
||||
set_next_b(b, NULL); // ditto
|
||||
|
||||
@ -2433,7 +2433,7 @@ VALGRIND_PRINTF_BACKTRACE(const char *format, ...)
|
||||
|
||||
If you're allocating memory via superblocks, and then handing out small
|
||||
chunks of each superblock, if you don't have redzones on your small
|
||||
blocks, it's worth marking the superblock with VALGRIND_MAKE_NOACCESS
|
||||
blocks, it's worth marking the superblock with VALGRIND_MAKE_MEM_NOACCESS
|
||||
when it's created, so that block overruns are detected. But if you can
|
||||
put redzones on, it's probably better to not do this, so that messages
|
||||
for small overruns are described in terms of the small block rather than
|
||||
|
||||
@ -995,9 +995,9 @@ arguments.</para>
|
||||
<itemizedlist>
|
||||
|
||||
<listitem>
|
||||
<para><varname>VALGRIND_MAKE_NOACCESS</varname>,
|
||||
<varname>VALGRIND_MAKE_WRITABLE</varname> and
|
||||
<varname>VALGRIND_MAKE_READABLE</varname>.
|
||||
<para><varname>VALGRIND_MAKE_MEM_NOACCESS</varname>,
|
||||
<varname>VALGRIND_MAKE_MEM_UNDEFINED</varname> and
|
||||
<varname>VALGRIND_MAKE_MEM_DEFINED</varname>.
|
||||
These mark address ranges as completely inaccessible,
|
||||
accessible but containing undefined data, and accessible and
|
||||
containing defined data, respectively. Subsequent errors may
|
||||
@ -1006,6 +1006,12 @@ arguments.</para>
|
||||
on Valgrind.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><varname>VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE</varname>.
|
||||
This is just like <varname>VALGRIND_MAKE_MEM_DEFINED</varname> but only
|
||||
affects those bytes that are already addressable.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><varname>VALGRIND_DISCARD</varname>: At some point you may
|
||||
want Valgrind to stop reporting errors in terms of the blocks
|
||||
@ -1022,8 +1028,8 @@ arguments.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><varname>VALGRIND_CHECK_WRITABLE</varname> and
|
||||
<varname>VALGRIND_CHECK_READABLE</varname>: check immediately
|
||||
<para><varname>VALGRIND_CHECK_MEM_IS_ADDRESSABLE</varname> and
|
||||
<varname>VALGRIND_CHECK_MEM_IS_DEFINED</varname>: check immediately
|
||||
whether or not the given address range has the relevant property,
|
||||
and if not, print an error message. Also, for the convenience of
|
||||
the client, returns zero if the relevant property holds; otherwise,
|
||||
@ -1033,9 +1039,9 @@ arguments.</para>
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para><varname>VALGRIND_CHECK_DEFINED</varname>: a quick and easy
|
||||
way to find out whether Valgrind thinks a particular variable
|
||||
(lvalue, to be precise) is addressible and defined. Prints an error
|
||||
<para><varname>VALGRIND_CHECK_VALUE_IS_DEFINED</varname>: a quick and easy
|
||||
way to find out whether Valgrind thinks a particular value
|
||||
(lvalue, to be precise) is addressable and defined. Prints an error
|
||||
message if not. Returns no value.</para>
|
||||
</listitem>
|
||||
|
||||
|
||||
@ -96,10 +96,10 @@ extern VgHashTable MC_(malloc_list);
|
||||
extern VgHashTable MC_(mempool_list);
|
||||
|
||||
/* Shadow memory functions */
|
||||
extern Bool MC_(check_noaccess)( Addr a, SizeT len, Addr* bad_addr );
|
||||
extern void MC_(make_noaccess) ( Addr a, SizeT len );
|
||||
extern void MC_(make_writable) ( Addr a, SizeT len );
|
||||
extern void MC_(make_readable) ( Addr a, SizeT len );
|
||||
extern Bool MC_(check_mem_is_noaccess)( Addr a, SizeT len, Addr* bad_addr );
|
||||
extern void MC_(make_mem_noaccess) ( Addr a, SizeT len );
|
||||
extern void MC_(make_mem_undefined)( Addr a, SizeT len );
|
||||
extern void MC_(make_mem_defined) ( Addr a, SizeT len );
|
||||
extern void MC_(copy_address_range_state) ( Addr src, Addr dst, SizeT len );
|
||||
|
||||
extern void MC_(print_malloc_stats) ( void );
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -133,7 +133,7 @@ MC_Chunk* create_MC_Chunk ( ThreadId tid, Addr p, SizeT size,
|
||||
the mc->data field isn't visible to the leak checker. If memory
|
||||
management is working correctly, any pointer returned by VG_(malloc)
|
||||
should be noaccess as far as the client is concerned. */
|
||||
if (!MC_(check_noaccess)( (Addr)mc, sizeof(MC_Chunk), NULL )) {
|
||||
if (!MC_(check_mem_is_noaccess)( (Addr)mc, sizeof(MC_Chunk), NULL )) {
|
||||
VG_(tool_panic)("create_MC_Chunk: shadow area is accessible");
|
||||
}
|
||||
return mc;
|
||||
@ -192,9 +192,9 @@ void* MC_(new_block) ( ThreadId tid,
|
||||
VG_(HT_add_node)( table, create_MC_Chunk(tid, p, size, kind) );
|
||||
|
||||
if (is_zeroed)
|
||||
MC_(make_readable)( p, size );
|
||||
MC_(make_mem_defined)( p, size );
|
||||
else
|
||||
MC_(make_writable)( p, size );
|
||||
MC_(make_mem_undefined)( p, size );
|
||||
|
||||
return (void*)p;
|
||||
}
|
||||
@ -259,7 +259,7 @@ void die_and_free_mem ( ThreadId tid, MC_Chunk* mc, SizeT rzB )
|
||||
{
|
||||
/* Note: make redzones noaccess again -- just in case user made them
|
||||
accessible with a client request... */
|
||||
MC_(make_noaccess)( mc->data-rzB, mc->size + 2*rzB );
|
||||
MC_(make_mem_noaccess)( mc->data-rzB, mc->size + 2*rzB );
|
||||
|
||||
/* Put it out of harm's way for a while, if not from a client request */
|
||||
if (MC_AllocCustom != mc->allockind) {
|
||||
@ -345,7 +345,7 @@ void* MC_(realloc) ( ThreadId tid, void* p_old, SizeT new_size )
|
||||
|
||||
} else if (old_size > new_size) {
|
||||
/* new size is smaller */
|
||||
MC_(make_noaccess)( mc->data+new_size, mc->size-new_size );
|
||||
MC_(make_mem_noaccess)( mc->data+new_size, mc->size-new_size );
|
||||
mc->size = new_size;
|
||||
mc->where = VG_(record_ExeContext)(tid);
|
||||
p_new = p_old;
|
||||
@ -357,10 +357,10 @@ void* MC_(realloc) ( ThreadId tid, void* p_old, SizeT new_size )
|
||||
|
||||
if (a_new) {
|
||||
/* First half kept and copied, second half new, red zones as normal */
|
||||
MC_(make_noaccess)( a_new-MC_MALLOC_REDZONE_SZB, MC_MALLOC_REDZONE_SZB );
|
||||
MC_(make_mem_noaccess)( a_new-MC_MALLOC_REDZONE_SZB, MC_MALLOC_REDZONE_SZB );
|
||||
MC_(copy_address_range_state)( (Addr)p_old, a_new, mc->size );
|
||||
MC_(make_writable)( a_new+mc->size, new_size-mc->size );
|
||||
MC_(make_noaccess)( a_new+new_size, MC_MALLOC_REDZONE_SZB );
|
||||
MC_(make_mem_undefined)( a_new+mc->size, new_size-mc->size );
|
||||
MC_(make_mem_noaccess) ( a_new+new_size, MC_MALLOC_REDZONE_SZB );
|
||||
|
||||
/* Copy from old to new */
|
||||
VG_(memcpy)((void*)a_new, p_old, mc->size);
|
||||
@ -403,7 +403,7 @@ void MC_(create_mempool)(Addr pool, UInt rzB, Bool is_zeroed)
|
||||
management is working correctly, anything pointer returned by
|
||||
VG_(malloc) should be noaccess as far as the client is
|
||||
concerned. */
|
||||
if (!MC_(check_noaccess)( (Addr)mp, sizeof(MC_Mempool), NULL )) {
|
||||
if (!MC_(check_mem_is_noaccess)( (Addr)mp, sizeof(MC_Mempool), NULL )) {
|
||||
VG_(tool_panic)("MC_(create_mempool): shadow area is accessible");
|
||||
}
|
||||
|
||||
@ -428,7 +428,7 @@ void MC_(destroy_mempool)(Addr pool)
|
||||
while ( (mc = VG_(HT_Next)(mp->chunks)) ) {
|
||||
/* Note: make redzones noaccess again -- just in case user made them
|
||||
accessible with a client request... */
|
||||
MC_(make_noaccess)(mc->data-mp->rzB, mc->size + 2*mp->rzB );
|
||||
MC_(make_mem_noaccess)(mc->data-mp->rzB, mc->size + 2*mp->rzB );
|
||||
}
|
||||
// Destroy the chunk table
|
||||
VG_(HT_destruct)(mp->chunks);
|
||||
|
||||
@ -76,12 +76,12 @@
|
||||
ENTRIES, NOR DELETE ANY -- add new ones at the end. */
|
||||
typedef
|
||||
enum {
|
||||
VG_USERREQ__MAKE_NOACCESS = VG_USERREQ_TOOL_BASE('M','C'),
|
||||
VG_USERREQ__MAKE_WRITABLE,
|
||||
VG_USERREQ__MAKE_READABLE,
|
||||
VG_USERREQ__MAKE_MEM_NOACCESS = VG_USERREQ_TOOL_BASE('M','C'),
|
||||
VG_USERREQ__MAKE_MEM_UNDEFINED,
|
||||
VG_USERREQ__MAKE_MEM_DEFINED,
|
||||
VG_USERREQ__DISCARD,
|
||||
VG_USERREQ__CHECK_WRITABLE,
|
||||
VG_USERREQ__CHECK_READABLE,
|
||||
VG_USERREQ__CHECK_MEM_IS_ADDRESSABLE,
|
||||
VG_USERREQ__CHECK_MEM_IS_DEFINED,
|
||||
VG_USERREQ__DO_LEAK_CHECK,
|
||||
VG_USERREQ__COUNT_LEAKS,
|
||||
|
||||
@ -90,7 +90,7 @@ typedef
|
||||
|
||||
VG_USERREQ__CREATE_BLOCK,
|
||||
|
||||
VG_USERREQ__MAKE_DEFINED,
|
||||
VG_USERREQ__MAKE_MEM_DEFINED_IF_ADDRESSABLE,
|
||||
|
||||
/* This is just for memcheck's internal use - don't use it */
|
||||
_VG_USERREQ__MEMCHECK_RECORD_OVERLAP_ERROR
|
||||
@ -101,44 +101,54 @@ typedef
|
||||
|
||||
/* Client-code macros to manipulate the state of memory. */
|
||||
|
||||
/* Mark memory at _qzz_addr as unaddressible and undefined for
|
||||
_qzz_len bytes. */
|
||||
#define VALGRIND_MAKE_NOACCESS(_qzz_addr,_qzz_len) \
|
||||
/* Mark memory at _qzz_addr as unaddressable for _qzz_len bytes. */
|
||||
#define VALGRIND_MAKE_MEM_NOACCESS(_qzz_addr,_qzz_len) \
|
||||
(__extension__({unsigned int _qzz_res; \
|
||||
VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \
|
||||
VG_USERREQ__MAKE_NOACCESS, \
|
||||
VG_USERREQ__MAKE_MEM_NOACCESS, \
|
||||
_qzz_addr, _qzz_len, 0, 0, 0); \
|
||||
_qzz_res; \
|
||||
}))
|
||||
|
||||
/* Similarly, mark memory at _qzz_addr as addressible but undefined
|
||||
/* Similarly, mark memory at _qzz_addr as addressable but undefined
|
||||
for _qzz_len bytes. */
|
||||
#define VALGRIND_MAKE_MEM_UNDEFINED(_qzz_addr,_qzz_len) \
|
||||
(__extension__({unsigned int _qzz_res; \
|
||||
VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \
|
||||
VG_USERREQ__MAKE_MEM_UNDEFINED, \
|
||||
_qzz_addr, _qzz_len, 0, 0, 0); \
|
||||
_qzz_res; \
|
||||
}))
|
||||
|
||||
/* Similarly, mark memory at _qzz_addr as addressable and defined
|
||||
for _qzz_len bytes. */
|
||||
#define VALGRIND_MAKE_MEM_DEFINED(_qzz_addr,_qzz_len) \
|
||||
(__extension__({unsigned int _qzz_res; \
|
||||
VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \
|
||||
VG_USERREQ__MAKE_MEM_DEFINED, \
|
||||
_qzz_addr, _qzz_len, 0, 0, 0); \
|
||||
_qzz_res; \
|
||||
}))
|
||||
|
||||
/* This is the old name for VALGRIND_MAKE_MEM_NOACCESS. Deprecated. */
|
||||
#define VALGRIND_MAKE_NOACCESS(_qzz_addr,_qzz_len) \
|
||||
VALGRIND_MAKE_MEM_NOACCESS(_qzz_addr,_qzz_len)
|
||||
|
||||
/* This is the old name for VALGRIND_MAKE_MEM_UNDEFINED. Deprecated. */
|
||||
#define VALGRIND_MAKE_WRITABLE(_qzz_addr,_qzz_len) \
|
||||
(__extension__({unsigned int _qzz_res; \
|
||||
VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \
|
||||
VG_USERREQ__MAKE_WRITABLE, \
|
||||
_qzz_addr, _qzz_len, 0, 0, 0); \
|
||||
_qzz_res; \
|
||||
}))
|
||||
VALGRIND_MAKE_MEM_UNDEFINED(_qzz_addr,_qzz_len)
|
||||
|
||||
/* Similarly, mark memory at _qzz_addr as addressible and defined
|
||||
for _qzz_len bytes. */
|
||||
/* This is the old name for VALGRIND_MAKE_MEM_DEFINED. Deprecated. */
|
||||
#define VALGRIND_MAKE_READABLE(_qzz_addr,_qzz_len) \
|
||||
(__extension__({unsigned int _qzz_res; \
|
||||
VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \
|
||||
VG_USERREQ__MAKE_READABLE, \
|
||||
_qzz_addr, _qzz_len, 0, 0, 0); \
|
||||
_qzz_res; \
|
||||
}))
|
||||
VALGRIND_MAKE_MEM_DEFINED(_qzz_addr,_qzz_len)
|
||||
|
||||
/* Similar to mark memory at VALGRIND_MAKE_READABLE except that
|
||||
addressibility is not altered: bytes which are addressible are
|
||||
marked as defined, but those which are not addressible are
|
||||
left unchanged. */
|
||||
#define VALGRIND_MAKE_DEFINED(_qzz_addr,_qzz_len) \
|
||||
/* Similar to VALGRIND_MAKE_MEM_DEFINED except that addressability is
|
||||
not altered: bytes which are addressable are marked as defined,
|
||||
but those which are not addressable are left unchanged. */
|
||||
#define VALGRIND_MAKE_MEM_DEFINED_IF_ADDRESSABLE(_qzz_addr,_qzz_len) \
|
||||
(__extension__({unsigned int _qzz_res; \
|
||||
VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0 /* default return */, \
|
||||
VG_USERREQ__MAKE_DEFINED, \
|
||||
VG_USERREQ__MAKE_MEM_DEFINED_IF_ADDRESSABLE, \
|
||||
_qzz_addr, _qzz_len, 0, 0, 0); \
|
||||
_qzz_res; \
|
||||
}))
|
||||
@ -169,40 +179,53 @@ typedef
|
||||
|
||||
/* Client-code macros to check the state of memory. */
|
||||
|
||||
/* Check that memory at _qzz_addr is addressible for _qzz_len bytes.
|
||||
/* Check that memory at _qzz_addr is addressable for _qzz_len bytes.
|
||||
If suitable addressibility is not established, Valgrind prints an
|
||||
error message and returns the address of the first offending byte.
|
||||
Otherwise it returns zero. */
|
||||
#define VALGRIND_CHECK_WRITABLE(_qzz_addr,_qzz_len) \
|
||||
#define VALGRIND_CHECK_MEM_IS_ADDRESSABLE(_qzz_addr,_qzz_len) \
|
||||
(__extension__({unsigned int _qzz_res; \
|
||||
VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \
|
||||
VG_USERREQ__CHECK_WRITABLE, \
|
||||
VG_USERREQ__CHECK_MEM_IS_ADDRESSABLE,\
|
||||
_qzz_addr, _qzz_len, 0, 0, 0); \
|
||||
_qzz_res; \
|
||||
}))
|
||||
|
||||
/* Check that memory at _qzz_addr is addressible and defined for
|
||||
/* Check that memory at _qzz_addr is addressable and defined for
|
||||
_qzz_len bytes. If suitable addressibility and definedness are not
|
||||
established, Valgrind prints an error message and returns the
|
||||
address of the first offending byte. Otherwise it returns zero. */
|
||||
#define VALGRIND_CHECK_READABLE(_qzz_addr,_qzz_len) \
|
||||
#define VALGRIND_CHECK_MEM_IS_DEFINED(_qzz_addr,_qzz_len) \
|
||||
(__extension__({unsigned int _qzz_res; \
|
||||
VALGRIND_DO_CLIENT_REQUEST(_qzz_res, 0, \
|
||||
VG_USERREQ__CHECK_READABLE, \
|
||||
VG_USERREQ__CHECK_MEM_IS_DEFINED, \
|
||||
_qzz_addr, _qzz_len, 0, 0, 0); \
|
||||
_qzz_res; \
|
||||
}))
|
||||
|
||||
/* Use this macro to force the definedness and addressibility of a
|
||||
value to be checked. If suitable addressibility and definedness
|
||||
/* Use this macro to force the definedness and addressibility of an
|
||||
lvalue to be checked. If suitable addressibility and definedness
|
||||
are not established, Valgrind prints an error message and returns
|
||||
the address of the first offending byte. Otherwise it returns
|
||||
zero. */
|
||||
#define VALGRIND_CHECK_DEFINED(__lvalue) \
|
||||
VALGRIND_CHECK_READABLE( \
|
||||
#define VALGRIND_CHECK_VALUE_IS_DEFINED(__lvalue) \
|
||||
VALGRIND_CHECK_MEM_IS_DEFINED( \
|
||||
(volatile unsigned char *)&(__lvalue), \
|
||||
(unsigned int)(sizeof (__lvalue)))
|
||||
|
||||
/* This is the old name for VALGRIND_CHECK_MEM_IS_ADDRESSABLE. Deprecated. */
|
||||
#define VALGRIND_CHECK_WRITABLE(_qzz_addr,_qzz_len) \
|
||||
VALGRIND_CHECK_MEM_IS_ADDRESSABLE(_qzz_addr,_qzz_len)
|
||||
|
||||
/* This is the old name for VALGRIND_CHECK_MEM_IS_DEFINED. Deprecated. */
|
||||
#define VALGRIND_CHECK_READABLE(_qzz_addr,_qzz_len) \
|
||||
VALGRIND_CHECK_MEM_IS_DEFINED(_qzz_addr,_qzz_len)
|
||||
|
||||
/* This is the old name for VALGRIND_CHECK_VALUE_IS_DEFINED. Deprecated. */
|
||||
#define VALGRIND_CHECK_DEFINED(__lvalue) \
|
||||
VALGRIND_CHECK_VALUE_IS_DEFINED(__lvalue)
|
||||
|
||||
|
||||
/* Do a memory leak check mid-execution. */
|
||||
#define VALGRIND_DO_LEAK_CHECK \
|
||||
{unsigned int _qzz_res; \
|
||||
@ -236,7 +259,7 @@ typedef
|
||||
0 if not running on valgrind
|
||||
1 success
|
||||
2 [previously indicated unaligned arrays; these are now allowed]
|
||||
3 if any parts of zzsrc/zzvbits are not addressible.
|
||||
3 if any parts of zzsrc/zzvbits are not addressable.
|
||||
The metadata is not copied in cases 0, 2 or 3 so it should be
|
||||
impossible to segfault your system by using this call.
|
||||
*/
|
||||
@ -255,7 +278,7 @@ typedef
|
||||
0 if not running on valgrind
|
||||
1 success
|
||||
2 [previously indicated unaligned arrays; these are now allowed]
|
||||
3 if any parts of zza/zzvbits are not addressible.
|
||||
3 if any parts of zza/zzvbits are not addressable.
|
||||
The metadata is not copied in cases 0, 2 or 3 so it should be
|
||||
impossible to segfault your system by using this call.
|
||||
*/
|
||||
|
||||
@ -34,18 +34,18 @@ static void test1()
|
||||
{
|
||||
char *m = mm(0, pgsz * 5, PROT_READ);
|
||||
|
||||
VALGRIND_CHECK_READABLE(m, pgsz*5); /* all defined */
|
||||
VALGRIND_CHECK_MEM_IS_DEFINED(m, pgsz*5); /* all defined */
|
||||
}
|
||||
|
||||
/* Case 2 - unmapped memory is unaddressable+undefined */
|
||||
static void test2()
|
||||
{
|
||||
char *m = mm(0, pgsz * 5, PROT_READ|PROT_WRITE);
|
||||
VALGRIND_CHECK_READABLE(m, pgsz*5); /* all OK */
|
||||
VALGRIND_CHECK_MEM_IS_DEFINED(m, pgsz*5); /* all OK */
|
||||
|
||||
munmap(&m[pgsz*2], pgsz);
|
||||
|
||||
VALGRIND_CHECK_READABLE(&m[pgsz*2], pgsz); /* undefined */
|
||||
VALGRIND_CHECK_MEM_IS_DEFINED(&m[pgsz*2], pgsz); /* undefined */
|
||||
|
||||
/* XXX need a memcheck request to test addressability */
|
||||
m[pgsz*2] = 'x'; /* unmapped fault */
|
||||
@ -56,9 +56,9 @@ static void test3()
|
||||
{
|
||||
char *m = mm(0, pgsz * 5, PROT_READ|PROT_WRITE);
|
||||
|
||||
VALGRIND_MAKE_WRITABLE(&m[pgsz], pgsz);
|
||||
VALGRIND_MAKE_MEM_UNDEFINED(&m[pgsz], pgsz);
|
||||
mm(&m[pgsz], pgsz, PROT_READ);
|
||||
VALGRIND_CHECK_READABLE(&m[pgsz], pgsz); /* OK */
|
||||
VALGRIND_CHECK_MEM_IS_DEFINED(&m[pgsz], pgsz); /* OK */
|
||||
}
|
||||
|
||||
/* Case 4 - mprotect doesn't affect addressability */
|
||||
@ -67,7 +67,7 @@ static void test4()
|
||||
char *m = mm(0, pgsz * 5, PROT_READ|PROT_WRITE);
|
||||
|
||||
mprotect(m, pgsz, PROT_WRITE);
|
||||
VALGRIND_CHECK_READABLE(m, pgsz); /* OK */
|
||||
VALGRIND_CHECK_MEM_IS_DEFINED(m, pgsz); /* OK */
|
||||
m[44] = 'y'; /* OK */
|
||||
|
||||
mprotect(m, pgsz*5, PROT_NONE);
|
||||
@ -79,16 +79,16 @@ static void test5()
|
||||
{
|
||||
char *m = mm(0, pgsz * 5, PROT_READ|PROT_WRITE);
|
||||
|
||||
VALGRIND_MAKE_WRITABLE (m, pgsz*5);
|
||||
VALGRIND_MAKE_MEM_UNDEFINED(m, pgsz*5);
|
||||
memset(m, 'x', 10);
|
||||
VALGRIND_CHECK_READABLE(m, 10); /* OK */
|
||||
VALGRIND_CHECK_READABLE(m+10, 10); /* BAD */
|
||||
VALGRIND_CHECK_MEM_IS_DEFINED(m, 10); /* OK */
|
||||
VALGRIND_CHECK_MEM_IS_DEFINED(m+10, 10); /* BAD */
|
||||
|
||||
mprotect(m, pgsz*5, PROT_NONE);
|
||||
mprotect(m, pgsz*5, PROT_READ);
|
||||
|
||||
VALGRIND_CHECK_READABLE(m, 10); /* still OK */
|
||||
VALGRIND_CHECK_READABLE(m+20, 10); /* BAD */
|
||||
VALGRIND_CHECK_MEM_IS_DEFINED(m, 10); /* still OK */
|
||||
VALGRIND_CHECK_MEM_IS_DEFINED(m+20, 10); /* BAD */
|
||||
}
|
||||
|
||||
static struct test {
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
int main1 ( void )
|
||||
{
|
||||
int xxx, i;
|
||||
for (i = 0; i < 10; i++) VALGRIND_CHECK_DEFINED(xxx);
|
||||
for (i = 0; i < 10; i++) VALGRIND_CHECK_VALUE_IS_DEFINED(xxx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -17,10 +17,10 @@ int main ( void )
|
||||
char* aa = calloc(100,1);
|
||||
sum = 0;
|
||||
|
||||
VALGRIND_CHECK_READABLE(aa,100);
|
||||
VALGRIND_CHECK_MEM_IS_DEFINED(aa,100);
|
||||
|
||||
m = VALGRIND_MAKE_WRITABLE( &aa[49], 1 );
|
||||
VALGRIND_CHECK_WRITABLE(aa,100);
|
||||
m = VALGRIND_MAKE_MEM_UNDEFINED( &aa[49], 1 );
|
||||
VALGRIND_CHECK_MEM_IS_ADDRESSABLE(aa,100);
|
||||
|
||||
printf("m_na: returned value is %d\n", m );
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ void* get_superblock(void)
|
||||
// program to be using it unless its handed out by custom_alloc()
|
||||
|
||||
// with redzones, better not to have it
|
||||
VALGRIND_MAKE_NOACCESS(p, SUPERBLOCK_SIZE);
|
||||
VALGRIND_MAKE_MEM_NOACCESS(p, SUPERBLOCK_SIZE);
|
||||
|
||||
return p;
|
||||
}
|
||||
@ -86,7 +86,7 @@ int main(void)
|
||||
custom_free(array3); // mismatched free (ok without MALLOCLIKE)
|
||||
|
||||
make_leak();
|
||||
return array[0]; // use after free (ok without MALLOCLIKE/MAKE_NOACCESS)
|
||||
return array[0]; // use after free (ok without MALLOCLIKE/MAKE_MEM_NOACCESS)
|
||||
// (nb: initialised because is_zeroed==1 above)
|
||||
// unfortunately not identified as being in a free'd
|
||||
// block because the freeing of the block and shadow
|
||||
|
||||
@ -40,7 +40,7 @@ pool *make_pool()
|
||||
|
||||
p->size = p->left = SUPERBLOCK_SIZE;
|
||||
p->levels = NULL;
|
||||
VALGRIND_MAKE_NOACCESS(p->where, SUPERBLOCK_SIZE);
|
||||
VALGRIND_MAKE_MEM_NOACCESS(p->where, SUPERBLOCK_SIZE);
|
||||
return p;
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ void pop(pool *p)
|
||||
level_list *l = p->levels;
|
||||
p->levels = l->next;
|
||||
VALGRIND_DESTROY_MEMPOOL(l->where);
|
||||
VALGRIND_MAKE_NOACCESS(l->where, p->where-l->where);
|
||||
VALGRIND_MAKE_MEM_NOACCESS(l->where, p->where-l->where);
|
||||
p->where = l->where;
|
||||
if(USE_MMAP)
|
||||
munmap(l, sizeof(level_list));
|
||||
|
||||
@ -67,7 +67,7 @@ int main()
|
||||
perror("trap 4 failed");
|
||||
else {
|
||||
munmap(map, 256*1024);
|
||||
VALGRIND_MAKE_READABLE(map, 256*1024); /* great big fat lie */
|
||||
VALGRIND_MAKE_MEM_DEFINED(map, 256*1024); /* great big fat lie */
|
||||
}
|
||||
|
||||
VALGRIND_DO_LEAK_CHECK;
|
||||
|
||||
@ -31,8 +31,8 @@ int main()
|
||||
if (ret != -1 || errno != EINTR) {
|
||||
printf("FAILED: expected nanosleep to be interrupted\n");
|
||||
} else {
|
||||
VALGRIND_CHECK_DEFINED(rem);
|
||||
printf("PASSED\n"); /* assuming CHECK_DEFINED doesn't print anything */
|
||||
VALGRIND_CHECK_VALUE_IS_DEFINED(rem);
|
||||
printf("PASSED\n"); /* assuming CHECK_VALUE_IS_DEFINED doesn't print anything */
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@ -41,7 +41,7 @@ U8 build(int size, U1 byte)
|
||||
U8 mask = 0;
|
||||
U8 shres;
|
||||
U8 res = 0xffffffffffffffffULL, res2;
|
||||
VALGRIND_MAKE_WRITABLE(&res, 8);
|
||||
VALGRIND_MAKE_MEM_UNDEFINED(&res, 8);
|
||||
assert(1 == size || 2 == size || 4 == size || 8 == size);
|
||||
|
||||
for (i = 0; i < size; i++) {
|
||||
@ -56,7 +56,7 @@ U8 build(int size, U1 byte)
|
||||
|
||||
VALGRIND_GET_VBITS(&res, &shres, 8);
|
||||
res2 = res;
|
||||
VALGRIND_MAKE_READABLE(&res2, 8); // avoid the 'undefined' warning
|
||||
VALGRIND_MAKE_MEM_DEFINED(&res2, 8); // avoid the 'undefined' warning
|
||||
assert(res2 == shres);
|
||||
return res;
|
||||
}
|
||||
@ -110,7 +110,7 @@ int main(void)
|
||||
//
|
||||
// which is useful for testing below.
|
||||
undefA = calloc(1, 256); // one for each possible undefinedness value
|
||||
VALGRIND_MAKE_WRITABLE(undefA, 256);
|
||||
VALGRIND_MAKE_MEM_UNDEFINED(undefA, 256);
|
||||
for (i = 0; i < 256; i++) {
|
||||
undefA[i] &= i;
|
||||
}
|
||||
@ -150,8 +150,8 @@ int main(void)
|
||||
/* the output of build() into a variable of type 'Ty'. */ \
|
||||
U8 tmpDef = tmp; \
|
||||
ITy undefN_ITyDef = undefN_ITy; \
|
||||
VALGRIND_MAKE_READABLE(&tmpDef, 8 ); \
|
||||
VALGRIND_MAKE_READABLE(&undefN_ITyDef, NNN); \
|
||||
VALGRIND_MAKE_MEM_DEFINED(&tmpDef, 8 ); \
|
||||
VALGRIND_MAKE_MEM_DEFINED(&undefN_ITyDef, NNN); \
|
||||
assert(tmpDef == (U8)undefN_ITyDef); \
|
||||
} \
|
||||
\
|
||||
|
||||
@ -821,7 +821,7 @@ int main(void)
|
||||
ss.ss_sp = NULL;
|
||||
ss.ss_flags = 0;
|
||||
ss.ss_size = 0;
|
||||
VALGRIND_MAKE_NOACCESS(& ss, sizeof(struct our_sigaltstack));
|
||||
VALGRIND_MAKE_MEM_NOACCESS(& ss, sizeof(struct our_sigaltstack));
|
||||
GO(__NR_sigaltstack, "2s 2m");
|
||||
SY(__NR_sigaltstack, x0+&ss, x0+&ss); SUCC;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user