This patch was developed in house for Bug 21658934. Python PyObject_Free()
implementation relies on being able to read memory that might not belong to
the current buffer. When ADIHEAP is enabled, this is detected as a violation.
Use an explicit nonfaulting load to ignore the ADI tag.
This patch only works with Studio; one which supports gcc and
Studio is being worked on with an intent to push it upstream.
--- a/Objects/obmalloc.c Wed Apr 13 11:52:46 2016 -0700
+++ b/Objects/obmalloc.c Thu Apr 14 07:00:32 2016 -0700
@@ -42,6 +42,18 @@
static int running_on_valgrind = -1;
#endif
+#ifdef __sparcv9
+#include <vis.h>
+/*
+ * Py_ADDRESS_IN_RANGE needs to access memory that might be arbitrarily
+ * tagged by an ADI aware allocator. The use of a nonfaulting load
+ * guarantees that the read will succeed.
+ */
+#define POOL_INDEX(x) __vis_ldswa_ASI_PNF(&(x))
+#else /* __sparcv9 */
+#define POOL_INDEX(x) (x)
+#endif /* __sparcv9 */
+
/* An object allocator for Python.
Here is an introduction to the layers of the Python memory architecture,
@@ -735,7 +747,7 @@
variable.
*/
#define Py_ADDRESS_IN_RANGE(P, POOL) \
- ((arenaindex_temp = (POOL)->arenaindex) < maxarenas && \
+ ((arenaindex_temp = POOL_INDEX((POOL)->arenaindex)) < maxarenas && \
(uptr)(P) - arenas[arenaindex_temp].address < (uptr)ARENA_SIZE && \
arenas[arenaindex_temp].address != 0)