Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Oct 2017 21:57:30 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 221337] -fsanitize=address (asan) fails on i386
Message-ID:  <bug-221337-8-WylSpTS3U6@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-221337-8@https.bugs.freebsd.org/bugzilla/>
References:  <bug-221337-8@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D221337

Dimitry Andric <dim@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|freebsd-bugs@FreeBSD.org    |dim@FreeBSD.org
             Status|Open                        |In Progress

--- Comment #10 from Dimitry Andric <dim@FreeBSD.org> ---
Created attachment 187379
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D187379&action=
=3Dedit
Ensure alignment of jemalloc's TSD is 8 bytes on 32-bit platforms

Here is a possible way of fixing this issue: it ensures that the big tsd_t
struct in contrib/jemalloc/src/tsd.c is aligned to 8 bytes, on !LP64 platfo=
rms
(i.e. i386, but it could also apply to arm or mips, if AddressSanitizer ever
gets to work there).

Before r319971, on i386 the TLS items in libc.so.7 added up to 80 bytes of
storage (a multiple of 8 bytes), assuming __je_tsd_initialized is aligned a=
t 4
bytes:

$ readelf -sW /usr/obj/head-r319970/usr/src/lib/libc/libc.so.7|grep -w TLS
  1139: 00000058     4 TLS     GLOBAL DEFAULT   17 _ThreadRuneLocale@@FBSD_=
1.3
   547: 00000054     4 TLS     LOCAL  DEFAULT   17 __thread_locale
   607: 00000000    64 TLS     LOCAL  DEFAULT   16 __je_tsd_tls
   608: 0000004c     1 TLS     LOCAL  DEFAULT   17 __je_tsd_initialized
  3088: 00000058     4 TLS     GLOBAL DEFAULT   17 _ThreadRuneLocale

With r319971, this increased quite a lot, to 2404 bytes (which is not a
multiple of 8 bytes anymore, unfortunately):

$ readelf -sW /usr/obj/head-r319971/usr/src/lib/libc/libc.so.7|grep -w TLS
  1139: 0000096c     4 TLS     GLOBAL DEFAULT   17 _ThreadRuneLocale@@FBSD_=
1.3
   441: 00000968     4 TLS     LOCAL  DEFAULT   17 __thread_locale
   500: 00000000  2388 TLS     LOCAL  DEFAULT   16 __je_tsd_tls
   502: 00000960     1 TLS     LOCAL  DEFAULT   17 __je_tsd_initialized
  2845: 0000096c     4 TLS     GLOBAL DEFAULT   17 _ThreadRuneLocale

All the growth is in the __je_tsd_tls struct, as you can see.  If this stru=
ct
is forced to align to 8 bytes, the total amount of TLS data also becomes
aligned to 8 bytes.

An alternative would be to unconditionally align the struct at, say, 16 byt=
es,
and get rid of the #ifdef.

Yet another alternative would be to place some bogus padding 4 byte entity
somewhere else in libc.so to ensure the TLS data is a multiple of 8 bytes.=
=20
Suggestions as to where are welcome. :)

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-221337-8-WylSpTS3U6>