commit:     76dafed4ccc9c99b6d30d8cba37e6ba13734645d
Author:     Mike Frysinger <vapier <AT> chromium <DOT> org>
AuthorDate: Fri May  5 19:47:12 2017 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri May  5 19:48:07 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=76dafed4

app-admin/sysstat: fix from Chromium OS for unaligned memory errors

 .../sysstat/files/sysstat-11.4.3-memalign.patch    | 40 ++++++++++++++++++++++
 ...stat-11.5.5.ebuild => sysstat-11.4.3-r1.ebuild} | 13 +++++--
 app-admin/sysstat/sysstat-11.5.5.ebuild            |  1 +
 3 files changed, 51 insertions(+), 3 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 00000000000..ab5fa7dbc95
--- /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 <[email protected]>
+
+--- 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) {                               
                 \

diff --git a/app-admin/sysstat/sysstat-11.5.5.ebuild 
b/app-admin/sysstat/sysstat-11.4.3-r1.ebuild
similarity index 84%
copy from app-admin/sysstat/sysstat-11.5.5.ebuild
copy to app-admin/sysstat/sysstat-11.4.3-r1.ebuild
index c9bea3b2b27..74edb096177 100644
--- a/app-admin/sysstat/sysstat-11.5.5.ebuild
+++ b/app-admin/sysstat/sysstat-11.4.3-r1.ebuild
@@ -10,10 +10,15 @@ SRC_URI="${HOMEPAGE}${P}.tar.xz"
 
 LICENSE="GPL-2"
 SLOT="0"
-KEYWORDS=""
-IUSE="debug nls lm_sensors selinux static"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh 
~sparc ~x86"
+IUSE="debug isag nls lm_sensors selinux static"
 
 CDEPEND="
+       isag? (
+               dev-lang/tk:0
+               dev-vcs/rcs
+               sci-visualization/gnuplot
+       )
        nls? ( virtual/libintl )
        lm_sensors? ( sys-apps/lm_sensors )
 "
@@ -28,6 +33,7 @@ RDEPEND="
 PATCHES=(
        "${FILESDIR}"/${PN}-10.0.4-flags.patch
        "${FILESDIR}"/${PN}-11.0.4-cron.patch
+       "${FILESDIR}"/${PN}-11.4.3-memalign.patch
 )
 
 SYSSTAT_FAKE_RC_DIR=Gentoo-does-not-use-rc.d
@@ -57,6 +63,7 @@ src_configure() {
                rcdir=${SYSSTAT_FAKE_RC_DIR} \
                econf \
                        $(use_enable debug debuginfo) \
+                       $(use_enable isag install-isag) \
                        $(use_enable lm_sensors sensors) \
                        $(use_enable nls) \
                        --enable-copy-only \
@@ -79,7 +86,7 @@ src_install() {
                MANGRPARG='' \
                install
 
-       dodoc -r contrib/
+       dodoc contrib/sargraph/sargraph
 
        rm -r "${D}/${SYSSTAT_FAKE_RC_DIR}" || die
        newinitd "${FILESDIR}"/${PN}.init.d ${PN}

diff --git a/app-admin/sysstat/sysstat-11.5.5.ebuild 
b/app-admin/sysstat/sysstat-11.5.5.ebuild
index c9bea3b2b27..73565a64f83 100644
--- a/app-admin/sysstat/sysstat-11.5.5.ebuild
+++ b/app-admin/sysstat/sysstat-11.5.5.ebuild
@@ -28,6 +28,7 @@ RDEPEND="
 PATCHES=(
        "${FILESDIR}"/${PN}-10.0.4-flags.patch
        "${FILESDIR}"/${PN}-11.0.4-cron.patch
+       "${FILESDIR}"/${PN}-11.4.3-memalign.patch
 )
 
 SYSSTAT_FAKE_RC_DIR=Gentoo-does-not-use-rc.d

Reply via email to