components/python/python35/patches/30-obmalloc-adi.patch
changeset 5936 56a9d82c570e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/python/python35/patches/30-obmalloc-adi.patch	Fri May 06 09:33:24 2016 -0700
@@ -0,0 +1,38 @@
+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        Thu Apr 14 10:33:32 2016 -0700
++++ b/Objects/obmalloc.c        Thu Apr 14 10:38:55 2016 -0700
+@@ -428,6 +428,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,
+@@ -1115,7 +1127,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)
+