summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@chromium.org>2017-05-05 15:47:12 -0400
committerMike Frysinger <vapier@gentoo.org>2017-05-05 15:48:07 -0400
commit76dafed4ccc9c99b6d30d8cba37e6ba13734645d (patch)
treea935c64cefe560ab0ed0e6e18d7213fad860a989 /app-admin/sysstat/files
parentsys-apps/s6: add ~arm, bug #609728 (diff)
downloadgentoo-76dafed4ccc9c99b6d30d8cba37e6ba13734645d.tar.gz
gentoo-76dafed4ccc9c99b6d30d8cba37e6ba13734645d.tar.bz2
gentoo-76dafed4ccc9c99b6d30d8cba37e6ba13734645d.zip
app-admin/sysstat: fix from Chromium OS for unaligned memory errors
Diffstat (limited to 'app-admin/sysstat/files')
-rw-r--r--app-admin/sysstat/files/sysstat-11.4.3-memalign.patch40
1 files changed, 40 insertions, 0 deletions
diff --git a/app-admin/sysstat/files/sysstat-11.4.3-memalign.patch b/app-admin/sysstat/files/sysstat-11.4.3-memalign.patch
new file mode 100644
index 000000000000..ab5fa7dbc95c
--- /dev/null
+++ b/app-admin/sysstat/files/sysstat-11.4.3-memalign.patch
@@ -0,0 +1,40 @@
+sysstat declares 16 bytes alignment for many structs. But realloc does not
+guarantee 16 byte alignment (it maxes out at 8 bytes for most systems).
+Because of declared 16 byte alignement, the compiler is free to generate SIMD
+16 byte loads which require aligned addresses. Use posix_memalign instead to
+enforce 16 bytes data alignment to avoid crashes.
+
+https://github.com/sysstat/sysstat/issues/148
+
+Patch by Manoj Gupta <manojgupta@google.com>
+
+--- a/common.h
++++ b/common.h
+@@ -11,6 +11,7 @@
+
+ #include <time.h>
+ #include <sched.h> /* For __CPU_SETSIZE */
++#include <stdlib.h>
+ #include <limits.h>
+
+ #ifdef HAVE_SYS_SYSMACROS_H
+@@ -91,13 +92,18 @@
+ TYPE *_p_; \
+ _p_ = S; \
+ if (SIZE) { \
+- if ((S = (TYPE *) realloc(S, (SIZE))) == NULL) { \
++ void *_ptr = NULL; \
++ int error = posix_memalign(&_ptr, 16, SIZE); \
++ if (error || _ptr == NULL) { \
+ perror("realloc"); \
+ exit(4); \
+ } \
++ S = (TYPE *)_ptr; \
+ /* If the ptr was null, then it's a malloc() */ \
+ if (!_p_) { \
+ memset(S, 0, (SIZE)); \
++ } else { \
++ memcpy(S, _p_, (SIZE)); \
+ } \
+ } \
+ if (!S) { \