Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Sep 2015 08:25:00 +0100
From:      Julien Grall <julien.grall@citrix.com>
To:        Andrew Turner <andrew@fubar.geek.nz>
Cc:        <jasone@freebsd.org>, freebsd-arm <freebsd-arm@freebsd.org>
Subject:   Re: arm64: userspace broken with jemalloc 4.0.0
Message-ID:  <55E552CC.9080206@citrix.com>
In-Reply-To: <20150831220647.67a4646d@bender.Home>
References:  <55E22CC0.9000306@citrix.com> <20150831220647.67a4646d@bender.Home>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi Andrew,

On 31/08/2015 22:06, Andrew Turner wrote:
> On Sat, 29 Aug 2015 23:05:52 +0100
> Julien Grall <julien.grall@citrix.com> wrote:
>> I've built the latest freebsd master (r287263) for arm64 today. While
>> trying to use the userspace I hit some ASSERT in jemalloc:
>>
>> # ls
>> <jemalloc>: /usr/src/freebsd/lib/libc/../../contrib/jemalloc/include/jemalloc/internal/arena.h:571:
>> Failed assertion: "pageind >= map_bias" pid 21 (ls), uid 0: exited on
>> signal 6 Abort trap
>>
>> It's happening every time with the command "ls".
>>
>> I tried to use the previous version of jemalloc (i.e reverting
>> all the patches up to "Update jemalloc to version 4.0.0" included)
>> and everything is working.
>>
>> Note that I'm using Freebsd as a Xen ARM guest although the only
>> difference is the version of jemalloc (4.0.0 vs 3.6.0).
>>
>> Does anyone using arm64 have seen a similar ASSERT?
>>
>> BTW, is there any way to rebuild only the libc rather than doing
>> make buildworld everytime I modified the jemalloc code?
>>
>> Regards,
>>
> 
> This is a bug in the runtime linkers handling of tls. The attached
> patch allows me to get to multiuser mode without anything hitting the
> above assert.

I ended up to a similar patch during the week-end (see below). Although
I was looking to the amd64/i386 definition of calculate_tls_offset which
is the same as ARM64. I didn't understand why it's working for this architecture
but not for ours.

Is there any possible bug in the amd64/i386 runtime too?

Regards,

commit 3ee52ef6864c2180979d3de92cdf56f18a408beb
Author: Julien Grall <julien.grall@citrix.com>
Date:   Mon Aug 31 01:28:53 2015 +0100

    rtld: fix

diff --git a/libexec/rtld-elf/aarch64/rtld_machdep.h b/libexec/rtld-elf/aarch64/rtld_machdep.h
index 1cb2029..ff4d60a 100644
--- a/libexec/rtld-elf/aarch64/rtld_machdep.h
+++ b/libexec/rtld-elf/aarch64/rtld_machdep.h
@@ -66,7 +66,7 @@ Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
 #define        calculate_first_tls_offset(size, align) \
        round(size, align)
 #define        calculate_tls_offset(prev_offset, prev_size, size, align) \
-       round((prev_offset) + (size), align)
+       round((prev_offset) + (prev_size), align)
 #define        calculate_tls_end(off, size)    ((off) + (size))

 #define        TLS_TCB_SIZE    8
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
index 1d91460..1a776da 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -4427,7 +4427,7 @@ allocate_tls(Obj_Entry *objs, void *oldtcb, size_t tcbsize, size_t tcbalign)
        dtv[1] = tls_max_index;

        for (obj = objs; obj; obj = obj->next) {
-           if (obj->tlsoffset > 0) {
+           if (obj->tlssize > 0) {
                addr = (Elf_Addr)tls + obj->tlsoffset;
                if (obj->tlsinitsize > 0)
                    memcpy((void*) addr, obj->tlsinit, obj->tlsinitsize);
-- 
Julien Grall



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?55E552CC.9080206>