diff options
author | Mike Frysinger <vapier@chromium.org> | 2017-05-05 15:47:12 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2017-05-05 15:48:07 -0400 |
commit | 76dafed4ccc9c99b6d30d8cba37e6ba13734645d (patch) | |
tree | a935c64cefe560ab0ed0e6e18d7213fad860a989 /app-admin/sysstat | |
parent | sys-apps/s6: add ~arm, bug #609728 (diff) | |
download | gentoo-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')
-rw-r--r-- | app-admin/sysstat/files/sysstat-11.4.3-memalign.patch | 40 | ||||
-rw-r--r-- | app-admin/sysstat/sysstat-11.4.3-r1.ebuild | 96 | ||||
-rw-r--r-- | app-admin/sysstat/sysstat-11.5.5.ebuild | 1 |
3 files changed, 137 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) { \ diff --git a/app-admin/sysstat/sysstat-11.4.3-r1.ebuild b/app-admin/sysstat/sysstat-11.4.3-r1.ebuild new file mode 100644 index 000000000000..74edb0961772 --- /dev/null +++ b/app-admin/sysstat/sysstat-11.4.3-r1.ebuild @@ -0,0 +1,96 @@ +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 +inherit flag-o-matic multilib systemd toolchain-funcs + +DESCRIPTION="System performance tools for Linux" +HOMEPAGE="http://pagesperso-orange.fr/sebastien.godard/" +SRC_URI="${HOMEPAGE}${P}.tar.xz" + +LICENSE="GPL-2" +SLOT="0" +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 ) +" +DEPEND=" + ${CDEPEND} + nls? ( sys-devel/gettext ) +" +RDEPEND=" + ${CDEPEND} + selinux? ( sec-policy/selinux-sysstat ) +" +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 + +src_prepare() { + if use nls; then + strip-linguas -i nls/ + local lingua pofile + for pofile in nls/*.po; do + lingua=${pofile/nls\/} + lingua=${lingua/.po} + if ! has ${lingua} ${LINGUAS}; then + rm "nls/${lingua}.po" || die + fi + done + fi + + default +} + +src_configure() { + tc-export AR + use static && append-ldflags -static + + sa_lib_dir=/usr/$(get_libdir)/sa \ + conf_dir=/etc \ + 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 \ + --enable-documentation \ + --enable-install-cron \ + --with-systemdsystemunitdir=$(systemd_get_systemunitdir) +} + +src_compile() { + emake LFLAGS="${LDFLAGS}" +} + +src_install() { + keepdir /var/log/sa + + emake \ + CHOWN=true \ + DESTDIR="${D}" \ + DOC_DIR=/usr/share/doc/${PF} \ + MANGRPARG='' \ + install + + dodoc contrib/sargraph/sargraph + + rm -r "${D}/${SYSSTAT_FAKE_RC_DIR}" || die + newinitd "${FILESDIR}"/${PN}.init.d ${PN} + systemd_dounit ${PN}.service + + rm -f "${D}"usr/share/doc/${PF}/COPYING +} diff --git a/app-admin/sysstat/sysstat-11.5.5.ebuild b/app-admin/sysstat/sysstat-11.5.5.ebuild index c9bea3b2b27c..73565a64f835 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 |