Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Jul 2024 21:08:46 +0300
From:      Konstantin Belousov <kib@freebsd.org>
To:        mmel@freebsd.org
Cc:        FreeBSD Current <freebsd-current@freebsd.org>, "freebsd-arm@freebsd.org" <freebsd-arm@freebsd.org>
Subject:   Re: armv7-on-aarch64 stuck at urdlck
Message-ID:  <Zp_xrkgW1iR7F41X@kib.kiev.ua>
In-Reply-To: <6a969609-fa0e-419d-83d5-e4fcf0f6ec35@freebsd.org>
References:  <B5E2275D-21F0-43C8-AF06-A45DB7448D66@yahoo.com> <86185657-e521-466b-89e2-f291aaac10a6@freebsd.org> <0EF18174-8735-46A4-BD71-FFA3472B319F@yahoo.com> <a1b978fe-ff54-4112-860c-b09500d89d0b@freebsd.org> <C0B42CBB-8F12-4597-A04B-26F2107E176E@yahoo.com> <33251aa3-681f-4d17-afe9-953490afeaf0@gmail.com> <0DD19771-3AAB-469E-981B-1203F1C28233@yahoo.com> <be023545-2b25-49ec-b6f1-9e05cd402646@gmail.com> <Zp95qtxK0CeDdp-d@kib.kiev.ua> <6a969609-fa0e-419d-83d5-e4fcf0f6ec35@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Jul 23, 2024 at 07:46:51PM +0200, Michal Meloun wrote:
> 
> 
> On 23.07.2024 11:36, Konstantin Belousov wrote:
> > On Tue, Jul 23, 2024 at 09:53:41AM +0200, Michal Meloun wrote:
> > > The good news is that I'm finally able to generate a working/locking
> > > test case.  The culprit (at least for me) is if "-mcpu" is used when
> > > compiling libthr (e.g. indirectly injected via CPUTYPE in /etc/make.conf).
> > > If it is not used, libthr is broken (regardless of -O level or debug/normal
> > > build), but -mcpu=cortex-a15 will always produce a working libthr.
> > 
> > I think this is very significant progress.
> > 
> > Do you plan to drill down more to see what is going on?
> 
> So the problem is now clear, and I fear it may apply to other architectures
> as well.
> dlopen_object() (from rtld_elf),
> https://cgit.freebsd.org/src/tree/libexec/rtld-elf/rtld.c#n3766,
> holds the rtld_bind_lock write lock for almost the entire time a new library
> is loaded.
> If the code uses a yet unresolved symbol to load the library, the rtl_bind()
> function attempts to get read lock of  rtld_bind_lock and a deadlock occurs.
> 
> In this case, it round_up() in _thr_stack_fix_protection,
> https://cgit.freebsd.org/src/tree/lib/libthr/thread/thr_stack.c#n136.
> Issued by __aeabi_uidiv (since not all armv7 processors support HW divide).
> 
> Unfortunately, I'm not sure how to fix it.  The compiler can emit __aeabi_<>
> in any place, and I'm not sure if it can resolve all the symbols used by
> rtld_eld and libthr beforehand.

This is a common issue, we pre-resolve a lot of symbols to avoid lock
recursion.  Please take a look at lib/libthr/thread/thr_rtld.c
_thr_rtld_init().



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