From owner-freebsd-arm@freebsd.org Tue Sep 1 07:25:20 2015 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 65C169C816D for ; Tue, 1 Sep 2015 07:25:20 +0000 (UTC) (envelope-from prvs=679187919=julien.grall@citrix.com) Received: from SMTP.CITRIX.COM (smtp.citrix.com [66.165.176.89]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (Client CN "mail.citrix.com", Issuer "Verizon Public SureServer CA G14-SHA2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E3945B4F; Tue, 1 Sep 2015 07:25:19 +0000 (UTC) (envelope-from prvs=679187919=julien.grall@citrix.com) X-IronPort-AV: E=Sophos;i="5.17,447,1437436800"; d="scan'208";a="296390289" Subject: Re: arm64: userspace broken with jemalloc 4.0.0 To: Andrew Turner References: <55E22CC0.9000306@citrix.com> <20150831220647.67a4646d@bender.Home> CC: , freebsd-arm From: Julien Grall Message-ID: <55E552CC.9080206@citrix.com> Date: Tue, 1 Sep 2015 08:25:00 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20150831220647.67a4646d@bender.Home> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-DLP: MIA1 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 07:25:20 -0000 Hi Andrew, On 31/08/2015 22:06, Andrew Turner wrote: > On Sat, 29 Aug 2015 23:05:52 +0100 > Julien Grall 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 >> : /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 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