components/python/python35/patches/30-obmalloc-adi.patch
author Enrico Perla <enrico.perla@oracle.com>
Fri, 06 May 2016 09:33:24 -0700
changeset 5936 56a9d82c570e
permissions -rw-r--r--
21658934 Python is not ADI-safe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5936
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
     1
This patch was developed in house for Bug 21658934. Python PyObject_Free()
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
     2
implementation relies on being able to read memory that might not belong to
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
     3
the current buffer. When ADIHEAP is enabled, this is detected as a violation.
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
     4
Use an explicit nonfaulting load to ignore the ADI tag.
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
     5
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
     6
This patch only works with Studio; one which supports gcc and
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
     7
Studio is being worked on with an intent to push it upstream.
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
     8
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
     9
--- a/Objects/obmalloc.c        Thu Apr 14 10:33:32 2016 -0700
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    10
+++ b/Objects/obmalloc.c        Thu Apr 14 10:38:55 2016 -0700
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    11
@@ -428,6 +428,18 @@
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    12
 static int running_on_valgrind = -1;
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    13
 #endif
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    14
 
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    15
+#ifdef __sparcv9
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    16
+#include <vis.h>
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    17
+/*
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    18
+ * Py_ADDRESS_IN_RANGE needs to access memory that might be arbitrarily
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    19
+ * tagged by an ADI aware allocator. The use of a nonfaulting load
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    20
+ * guarantees that the read will succeed.
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    21
+ */
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    22
+#define POOL_INDEX(x)   __vis_ldswa_ASI_PNF(&(x))
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    23
+#else   /* __sparcv9 */
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    24
+#define POOL_INDEX(x)   (x)
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    25
+#endif  /* __sparcv9 */
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    26
+
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    27
 /* An object allocator for Python.
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    28
 
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    29
    Here is an introduction to the layers of the Python memory architecture,
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    30
@@ -1115,7 +1127,7 @@
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    31
 variable.
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    32
 */
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    33
 #define Py_ADDRESS_IN_RANGE(P, POOL)                    \
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    34
-    ((arenaindex_temp = (POOL)->arenaindex) < maxarenas &&              \
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    35
+    ((arenaindex_temp = POOL_INDEX((POOL)->arenaindex)) < maxarenas && \
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    36
      (uptr)(P) - arenas[arenaindex_temp].address < (uptr)ARENA_SIZE && \
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    37
      arenas[arenaindex_temp].address != 0)
56a9d82c570e 21658934 Python is not ADI-safe
Enrico Perla <enrico.perla@oracle.com>
parents:
diff changeset
    38