From 7565f43fc1c544625d153f510b950f9f9bf6e848 Mon Sep 17 00:00:00 2001 From: Thomas Deutschmann Date: Tue, 1 Nov 2016 16:22:38 +0100 Subject: dev-libs/jemalloc: Patch added to fix an issue with sys-apps/sandbox Cherry picked commit c443b67561 [Link 1] which fixes an issue which prevented any jemalloc-enabled application from running through sys-apps/sandbox (typical use case is emerge with FEATURES=sandbox and FEATURES=test). Cherry picked commit 3c8c3e9e9b [Link 2] which fixes a leaked file descriptor. Link 1: https://github.com/jemalloc/jemalloc/commit/c443b67561891ae68d688daf5f8ce37820cdba2b Link 2: https://github.com/jemalloc/jemalloc/commit/3c8c3e9e9b59b6e34a222816a05f0a01a68919b3 Gentoo-Bug: https://bugs.gentoo.org/592420 Package-Manager: portage-2.3.2 --- .../jemalloc/files/jemalloc-4.2-issue_399.patch | 26 ++++++++++ .../jemalloc/files/jemalloc-4.2-issue_443.patch | 58 ++++++++++++++++++++++ dev-libs/jemalloc/jemalloc-4.2.1-r1.ebuild | 49 ++++++++++++++++++ dev-libs/jemalloc/jemalloc-4.2.1.ebuild | 47 ------------------ 4 files changed, 133 insertions(+), 47 deletions(-) create mode 100644 dev-libs/jemalloc/files/jemalloc-4.2-issue_399.patch create mode 100644 dev-libs/jemalloc/files/jemalloc-4.2-issue_443.patch create mode 100644 dev-libs/jemalloc/jemalloc-4.2.1-r1.ebuild delete mode 100644 dev-libs/jemalloc/jemalloc-4.2.1.ebuild diff --git a/dev-libs/jemalloc/files/jemalloc-4.2-issue_399.patch b/dev-libs/jemalloc/files/jemalloc-4.2-issue_399.patch new file mode 100644 index 000000000000..da9f2d8ad771 --- /dev/null +++ b/dev-libs/jemalloc/files/jemalloc-4.2-issue_399.patch @@ -0,0 +1,26 @@ +From 3c8c3e9e9b59b6e34a222816a05f0a01a68919b3 Mon Sep 17 00:00:00 2001 +From: Jason Evans +Date: Mon, 26 Sep 2016 15:55:40 -0700 +Subject: [PATCH] Close file descriptor after reading + "/proc/sys/vm/overcommit_memory". + +This bug was introduced by c2f970c32b527660a33fa513a76d913c812dcf7c +(Modify pages_map() to support mapping uncommitted virtual memory.). + +This resolves #399. +--- + src/pages.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/pages.c b/src/pages.c +index 2a9b7e3..05b0d69 100644 +--- a/src/pages.c ++++ b/src/pages.c +@@ -219,6 +219,7 @@ os_overcommits_proc(void) + return (false); /* Error. */ + + nread = read(fd, &buf, sizeof(buf)); ++ close(fd); + if (nread < 1) + return (false); /* Error. */ + /* diff --git a/dev-libs/jemalloc/files/jemalloc-4.2-issue_443.patch b/dev-libs/jemalloc/files/jemalloc-4.2-issue_443.patch new file mode 100644 index 000000000000..d2b065a3b6e0 --- /dev/null +++ b/dev-libs/jemalloc/files/jemalloc-4.2-issue_443.patch @@ -0,0 +1,58 @@ +From c443b67561891ae68d688daf5f8ce37820cdba2b Mon Sep 17 00:00:00 2001 +From: Jason Evans +Date: Sat, 29 Oct 2016 22:41:04 -0700 +Subject: [PATCH] Use syscall(2) rather than {open,read,close}(2) during boot. + +Some applications wrap various system calls, and if they call the +allocator in their wrappers, unexpected reentry can result. This is not +a general solution (many other syscalls are spread throughout the code), +but this resolves a bootstrapping issue that is apparently common. + +This resolves #443. +--- + src/pages.c | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +diff --git a/src/pages.c b/src/pages.c +index 05b0d69..84e2216 100644 +--- a/src/pages.c ++++ b/src/pages.c +@@ -207,6 +207,11 @@ os_overcommits_sysctl(void) + #endif + + #ifdef JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY ++/* ++ * Use syscall(2) rather than {open,read,close}(2) when possible to avoid ++ * reentry during bootstrapping if another library has interposed system call ++ * wrappers. ++ */ + static bool + os_overcommits_proc(void) + { +@@ -214,12 +219,26 @@ os_overcommits_proc(void) + char buf[1]; + ssize_t nread; + ++#ifdef SYS_open ++ fd = (int)syscall(SYS_open, "/proc/sys/vm/overcommit_memory", O_RDONLY); ++#else + fd = open("/proc/sys/vm/overcommit_memory", O_RDONLY); ++#endif + if (fd == -1) + return (false); /* Error. */ + ++#ifdef SYS_read ++ nread = (ssize_t)syscall(SYS_read, fd, &buf, sizeof(buf)); ++#else + nread = read(fd, &buf, sizeof(buf)); ++#endif ++ ++#ifdef SYS_close ++ syscall(SYS_close, fd); ++#else + close(fd); ++#endif ++ + if (nread < 1) + return (false); /* Error. */ + /* diff --git a/dev-libs/jemalloc/jemalloc-4.2.1-r1.ebuild b/dev-libs/jemalloc/jemalloc-4.2.1-r1.ebuild new file mode 100644 index 000000000000..c7f3d8aa79e6 --- /dev/null +++ b/dev-libs/jemalloc/jemalloc-4.2.1-r1.ebuild @@ -0,0 +1,49 @@ +# Copyright 1999-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +EAPI=6 + +inherit toolchain-funcs multilib-build + +DESCRIPTION="Jemalloc is a general-purpose scalable concurrent allocator" +HOMEPAGE="http://www.canonware.com/jemalloc/" +SRC_URI="http://www.canonware.com/download/${PN}/${P}.tar.bz2" + +LICENSE="BSD" +SLOT="0/2" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~x86 ~amd64-linux ~x86-linux ~x64-macos" +IUSE="debug static-libs stats" +HTML_DOCS=( doc/jemalloc.html ) +PATCHES=( "${FILESDIR}/${PN}-3.5.1-strip-optimization.patch" + "${FILESDIR}/${PN}-3.5.1_fix_html_install.patch" + "${FILESDIR}/${PN}-4.2-issue_399.patch" + "${FILESDIR}/${PN}-4.2-issue_443.patch" +) +MULTILIB_WRAPPED_HEADERS=( /usr/include/jemalloc/jemalloc.h ) +# autotools-utils.eclass auto-adds configure options when static-libs is in IUSE +# but jemalloc doesn't implement them in its configure; need this here to +# supress the warnings until automagic is removed from the eclass +QA_CONFIGURE_OPTIONS="--enable-static --disable-static --enable-shared --disable-shared" + +multilib_src_configure() { + ECONF_SOURCE="${S}" econf \ + $(use_enable debug) + $(use_enable stats) +} + +multilib_src_install() { + # Copy man file which the Makefile looks for + cp "${S}/doc/jemalloc.3" "${BUILD_DIR}/doc" || die + emake DESTDIR="${D}" install +} + +multilib_src_install_all() { + if [[ ${CHOST} == *-darwin* ]] ; then + # fixup install_name, #437362 + install_name_tool \ + -id "${EPREFIX}"/usr/$(get_libdir)/libjemalloc.1.dylib \ + "${ED}"/usr/$(get_libdir)/libjemalloc.1.dylib || die + fi + use static-libs || find "${ED}" -name '*.a' -delete +} diff --git a/dev-libs/jemalloc/jemalloc-4.2.1.ebuild b/dev-libs/jemalloc/jemalloc-4.2.1.ebuild deleted file mode 100644 index 8c320ea1c37f..000000000000 --- a/dev-libs/jemalloc/jemalloc-4.2.1.ebuild +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 1999-2016 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id$ - -EAPI=6 - -inherit toolchain-funcs multilib-build - -DESCRIPTION="Jemalloc is a general-purpose scalable concurrent allocator" -HOMEPAGE="http://www.canonware.com/jemalloc/" -SRC_URI="http://www.canonware.com/download/${PN}/${P}.tar.bz2" - -LICENSE="BSD" -SLOT="0/2" -KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~x86 ~amd64-linux ~x86-linux ~x64-macos" -IUSE="debug static-libs stats" -HTML_DOCS=( doc/jemalloc.html ) -PATCHES=( "${FILESDIR}/${PN}-3.5.1-strip-optimization.patch" - "${FILESDIR}/${PN}-3.5.1_fix_html_install.patch" -) -MULTILIB_WRAPPED_HEADERS=( /usr/include/jemalloc/jemalloc.h ) -# autotools-utils.eclass auto-adds configure options when static-libs is in IUSE -# but jemalloc doesn't implement them in its configure; need this here to -# supress the warnings until automagic is removed from the eclass -QA_CONFIGURE_OPTIONS="--enable-static --disable-static --enable-shared --disable-shared" - -multilib_src_configure() { - ECONF_SOURCE="${S}" econf \ - $(use_enable debug) - $(use_enable stats) -} - -multilib_src_install() { - # Copy man file which the Makefile looks for - cp "${S}/doc/jemalloc.3" "${BUILD_DIR}/doc" || die - emake DESTDIR="${D}" install -} - -multilib_src_install_all() { - if [[ ${CHOST} == *-darwin* ]] ; then - # fixup install_name, #437362 - install_name_tool \ - -id "${EPREFIX}"/usr/$(get_libdir)/libjemalloc.1.dylib \ - "${ED}"/usr/$(get_libdir)/libjemalloc.1.dylib || die - fi - use static-libs || find "${ED}" -name '*.a' -delete -} -- cgit v1.2.3-18-g5258