summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hawkins <phawkins@google.com>2022-12-13 20:23:57 +0000
committerPeter Hawkins <phawkins@google.com>2022-12-13 20:25:26 +0000
commit5940b4277a8212da9d802860430bdbf35855dddf (patch)
tree91c69a0b5aea71de707c47e7eff9f76e24e24a07
parent3139a881346ff7ad4326ecd296e6eeddf6c268a0 (diff)
downloadnumpy-5940b4277a8212da9d802860430bdbf35855dddf.tar.gz
Change argument to npy_floatstatus_..._barrier() functions to ensure it
is in bounds. The argument is dereferenced, even if the value is thrown away. AddressSanitizer reports an error on the dereference for these functions when running the NumPy test suite. It's unclear to me whether this is a legal fix or not, or whether we need to work harder to find a valid pointer that points within one of the arrays. This depends deeply on the semantics of `volatile` in C and I'm not 100% sure.
-rw-r--r--numpy/core/src/multiarray/array_assign_array.c4
-rw-r--r--numpy/core/src/multiarray/ctors.c2
2 files changed, 3 insertions, 3 deletions
diff --git a/numpy/core/src/multiarray/array_assign_array.c b/numpy/core/src/multiarray/array_assign_array.c
index 9d5bf6875..7aee7d6e9 100644
--- a/numpy/core/src/multiarray/array_assign_array.c
+++ b/numpy/core/src/multiarray/array_assign_array.c
@@ -130,7 +130,7 @@ raw_array_assign_array(int ndim, npy_intp const *shape,
}
if (!(flags & NPY_METH_NO_FLOATINGPOINT_ERRORS)) {
- npy_clear_floatstatus_barrier(src_data);
+ npy_clear_floatstatus_barrier((char*)&src_data);
}
if (!(flags & NPY_METH_REQUIRES_PYAPI)) {
NPY_BEGIN_THREADS;
@@ -153,7 +153,7 @@ raw_array_assign_array(int ndim, npy_intp const *shape,
NPY_cast_info_xfree(&cast_info);
if (!(flags & NPY_METH_NO_FLOATINGPOINT_ERRORS)) {
- int fpes = npy_get_floatstatus_barrier(src_data);
+ int fpes = npy_get_floatstatus_barrier((char*)&src_data);
if (fpes && PyUFunc_GiveFloatingpointErrors("cast", fpes) < 0) {
return -1;
}
diff --git a/numpy/core/src/multiarray/ctors.c b/numpy/core/src/multiarray/ctors.c
index 280cdb0c7..fa3b103dd 100644
--- a/numpy/core/src/multiarray/ctors.c
+++ b/numpy/core/src/multiarray/ctors.c
@@ -2834,7 +2834,7 @@ PyArray_CopyAsFlat(PyArrayObject *dst, PyArrayObject *src, NPY_ORDER order)
}
if (res == 0 && !(flags & NPY_METH_NO_FLOATINGPOINT_ERRORS)) {
- int fpes = npy_get_floatstatus_barrier((char *)src_iter);
+ int fpes = npy_get_floatstatus_barrier((char *)&src_iter);
if (fpes && PyUFunc_GiveFloatingpointErrors("cast", fpes) < 0) {
return -1;
}