[Pkg-mongodb-maintainers] [pkg-mongodb] 02/03: Fix segfault/FTBFS on ARM64 with 48-bit virtual addresses

Apollon Oikonomopoulos apoikos at moszumanska.debian.org
Mon Sep 25 20:55:23 UTC 2017


This is an automated email from the git hooks/post-receive script.

apoikos pushed a commit to annotated tag debian/1%3.2.11-4
in repository pkg-mongodb.

commit 9e6dd7a95e35dce0a1774ce3f468b2368a7627ac
Author: Apollon Oikonomopoulos <apoikos at debian.org>
Date:   Mon Sep 25 23:49:07 2017 +0300

    Fix segfault/FTBFS on ARM64 with 48-bit virtual addresses
    
    Backport upstream commit dfaafbaaa291, fixing mozjs segfaults on ARM64
    systems with 48-bit virtual addressing.
    
    Closes: #871906
---
 debian/patches/arm64-48bit-va-compat.patch | 61 ++++++++++++++++++++++++++++++
 debian/patches/series                      |  1 +
 2 files changed, 62 insertions(+)

diff --git a/debian/patches/arm64-48bit-va-compat.patch b/debian/patches/arm64-48bit-va-compat.patch
new file mode 100644
index 0000000..7cea6be
--- /dev/null
+++ b/debian/patches/arm64-48bit-va-compat.patch
@@ -0,0 +1,61 @@
+Author: Zheng Xu <zheng.xu at linaro.org>
+ Description: Manually mmap on arm64 to ensure high 17 bits are clear. r=ehoogeveen
+ There might be 48-bit VA on arm64 depending on kernel configuration.
+ Manually mmap heap memory to align with the assumption made by JS engine.
+Comment: Obtained from https://hg.mozilla.org/mozilla-central/raw-rev/dfaafbaaa291
+Last-Update: 2017-09-25
+Forwarded: no
+Bug-Debian: https://bugs.debian.org/871906
+--- a/src/third_party/mozjs-38/extract/js/src/gc/Memory.cpp
++++ b/src/third_party/mozjs-38/extract/js/src/gc/Memory.cpp
+@@ -379,7 +379,7 @@
+ MapMemoryAt(void* desired, size_t length, int prot = PROT_READ | PROT_WRITE,
+             int flags = MAP_PRIVATE | MAP_ANON, int fd = -1, off_t offset = 0)
+ {
+-#if defined(__ia64__) || (defined(__sparc64__) && defined(__NetBSD__))
++#if defined(__ia64__) || (defined(__sparc64__) && defined(__NetBSD__)) || defined(__aarch64__)
+     MOZ_ASSERT(0xffff800000000000ULL & (uintptr_t(desired) + length - 1) == 0);
+ #endif
+     void* region = mmap(desired, length, prot, flags, fd, offset);
+@@ -429,6 +429,41 @@
+         return nullptr;
+     }
+     return region;
++#elif defined(__aarch64__)
++   /*
++    * There might be similar virtual address issue on arm64 which depends on
++    * hardware and kernel configurations. But the work around is slightly
++    * different due to the different mmap behavior.
++    *
++    * TODO: Merge with the above code block if this implementation works for
++    * ia64 and sparc64.
++    */
++    const uintptr_t start = UINT64_C(0x0000070000000000);
++    const uintptr_t end   = UINT64_C(0x0000800000000000);
++    const uintptr_t step  = ChunkSize;
++   /*
++    * Optimization options if there are too many retries in practice:
++    * 1. Examine /proc/self/maps to find an available address. This file is
++    *    not always available, however. In addition, even if we examine
++    *    /proc/self/maps, we may still need to retry several times due to
++    *    racing with other threads.
++    * 2. Use a global/static variable with lock to track the addresses we have
++    *    allocated or tried.
++    */
++    uintptr_t hint;
++    void* region = MAP_FAILED;
++    for (hint = start; region == MAP_FAILED && hint + length <= end; hint += step) {
++        region = mmap((void*)hint, length, prot, flags, fd, offset);
++        if (region != MAP_FAILED) {
++            if ((uintptr_t(region) + (length - 1)) & 0xffff800000000000) {
++                if (munmap(region, length)) {
++                    MOZ_ASSERT(errno == ENOMEM);
++                }
++                region = MAP_FAILED;
++            }
++        }
++    }
++    return region == MAP_FAILED ? nullptr : region;
+ #else
+     void* region = MozTaggedAnonymousMmap(nullptr, length, prot, flags, fd, offset, "js-gc-heap");
+     if (region == MAP_FAILED)
diff --git a/debian/patches/series b/debian/patches/series
index 72e969f..04379ff 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -9,3 +9,4 @@ CVE-2016-6494.patch
 use-mmapv1-on-i386
 fix-wt-checksum-on-arm64
 fix-ftbfs-with-gcc-7.patch
+arm64-48bit-va-compat.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mongodb/pkg-mongodb.git



More information about the Pkg-mongodb-maintainers mailing list