Public bug reported:

firebuild 0.8.6.1-3 fails to build in stonking-proposed on all architectures 
that run the test suite (amd64, amd64v3, arm64, armhf, ppc64el, s390x; riscv64 
only built because it uses nocheck):
https://launchpad.net/ubuntu/+source/firebuild/0.8.6.1-3

The integration test 25 "env fixup" hangs and the build is killed after
150 minutes of inactivity. 0.8.6.1-2 passed that test in stonking in
May, and Debian sid passes it with 0.8.6.1-3+b1.

Root cause: the Ubuntu fakeroot delta 2.1.4-1ubuntu1 (d/p/intercept-raw-
fchmodat2-syscalls.patch, LP: #1915924) adds a syscall() wrapper to
libfakeroot. When a program that uses jemalloc (such as firebuild) runs
under fakeroot, it deadlocks at startup.

Reproducer (stonking-proposed, inside the firebuild build tree):
  cd obj-*/test
  fakeroot ./run-firebuild -- /usr/bin/true    # hangs forever
It does not matter which command firebuild runs: GNU id, true, echo and sh -c 
true all hang.

Backtrace of the hung firebuild process:
  #0-3  pthread_mutex_lock (jemalloc init mutex, already held)
  #4-6  libjemalloc.so.2
  #7    malloc
  #8    _dl_exception_create_format (objname=libfakeroot-sysv.so, "undefined 
symbol: %s%s%s")
  #9    _dl_lookup_symbol_x (undef_name="acl_get_fd")
  #11   _dl_sym / dlsym
  #18   load_library_symbols () libfakeroot-sysv.so
  #19   tmp_syscall () libfakeroot-sysv.so
  #20   syscall () libfakeroot-sysv.so      <- new Ubuntu wrapper
  #21-23 libjemalloc.so.2 (init, holding its init mutex)
  #24   libstdc++ static initializer -> malloc
  #27   _dl_init

So jemalloc calls syscall() during initialisation while it holds its
init mutex. The new libfakeroot syscall() wrapper then lazily resolves
all of its real symbols. dlsym("acl_get_fd") fails, and glibc calls
malloc() to format the error message. That re-enters jemalloc and blocks
on the same non-recursive mutex.

This affects any program linked with jemalloc (and probably other
allocators that call syscall() during init) when it runs under fakeroot,
not just firebuild.

Possible fixes in fakeroot:
 - In the syscall() wrapper, resolve only the real syscall with 
dlsym(RTLD_NEXT, "syscall") instead of calling load_library_symbols(). That 
lookup succeeds, so glibc does not allocate an error string.
 - Or add a guard against re-entry and forward straight to the real syscall 
while symbols are being loaded.
 - Or drop the delta once uutils stops issuing raw fchmodat2 (LP: #2164536).

firebuild does not need a change. Its migration is blocked until
fakeroot is fixed.

** Affects: fakeroot (Ubuntu)
     Importance: Undecided
     Assignee: Nadzeya Hutsko (nadzeya)
         Status: New

** Affects: firebuild (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: ftbfs update-excuse

** Tags added: ftbfs update-excuse

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2169262

Title:
  syscall() wrapper from intercept-raw-fchmodat2-syscalls.patch
  deadlocks jemalloc-linked programs under fakeroot (firebuild FTBFS)

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/fakeroot/+bug/2169262/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to