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

next in thread | previous in thread | raw e-mail | index | archive | help
--MP_/pkK1f/3q6zRGlsC+dYMyV/F
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Sat, 29 Aug 2015 23:05:52 +0100
Julien Grall <julien.grall@citrix.com> wrote:

> Hi,
> 
> 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.

Andrew

-- 
ABT Systems Ltd
Unit 11, Hove Business Centre, Fonthill Road, Hove, BN3 6HA
Registered in England and Wales, No. 9285513

--MP_/pkK1f/3q6zRGlsC+dYMyV/F
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=0001-WIP-fix-for-AArch64-TLS.patch

>From 81e6769f103e0e40347469ae6940ca461295d607 Mon Sep 17 00:00:00 2001
From: Andrew Turner <andrew@fubar.geek.nz>
Date: Mon, 31 Aug 2015 21:59:32 +0100
Subject: [PATCH] WIP fix for AArch64 TLS

---
 libexec/rtld-elf/aarch64/rtld_machdep.h | 4 ++--
 libexec/rtld-elf/rtld.c                 | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/libexec/rtld-elf/aarch64/rtld_machdep.h b/libexec/rtld-elf/aarch64/rtld_machdep.h
index 1cb2029..a7b1900 100644
--- a/libexec/rtld-elf/aarch64/rtld_machdep.h
+++ b/libexec/rtld-elf/aarch64/rtld_machdep.h
@@ -64,9 +64,9 @@ Elf_Addr reloc_jmpslot(Elf_Addr *where, Elf_Addr target,
 #define	round(size, align) \
 	(((size) + (align) - 1) & ~((align) - 1))
 #define	calculate_first_tls_offset(size, align) \
-	round(size, align)
+	round(16, 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..eecfb0f 100644
--- a/libexec/rtld-elf/rtld.c
+++ b/libexec/rtld-elf/rtld.c
@@ -4611,7 +4611,7 @@ allocate_tls_offset(Obj_Entry *obj)
 	return true;
     }
 
-    if (obj->tlsindex == 1)
+    if (tls_last_offset == 0)
 	off = calculate_first_tls_offset(obj->tlssize, obj->tlsalign);
     else
 	off = calculate_tls_offset(tls_last_offset, tls_last_size,
-- 
2.4.6


--MP_/pkK1f/3q6zRGlsC+dYMyV/F--



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