Bug 28624 - openjdk 8/9 assume uni processor and gets stuck due to lack of cpu counting /proc fallback with glibc 2.34
Summary: openjdk 8/9 assume uni processor and gets stuck due to lack of cpu counting /...
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.34
: P2 normal
Target Milestone: 2.35
Assignee: Adhemerval Zanella
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-24 21:58 UTC by Arkadiusz Miskiewicz
Modified: 2021-11-26 11:40 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed: 2021-11-24 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arkadiusz Miskiewicz 2021-11-24 21:58:27 UTC
commit f13fb81ad3159543741e9132685335002a6d5df2
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 25 14:04:37 2021 -0300

    linux: Remove /proc/cpuinfo fallback on alpha and sparc

introduced in glibc 2.34 also removed generic /proc/cpuinfo fallback (sysdeps/unix/sysv/linux/getsysstats.c change).

That causes breakage with openjdk 8 and 9 (and variants like icedtea) when no sysfs is mounted (two my cases where this got visible was chroot()ed system and linux vserver guest). openjdk assumes then that system is uniprocessor, disables MP things in virtual machine and even simple "java --help" gets stuck on futex operations.

openjdk sources:
hotspot/src/os/linux/vm/os_linux.cpp for number of cpus checking
hotspot/src/share/vm/runtime/globals.hpp for AssumeMP

Newer openjdk like 11 defaults to multi processor, so the bug doesn't happen there.

Easy reproducer by Jan Palus:

systemd-run --wait -t -p InaccessiblePaths=/sys /usr/lib64/jvm/openjdk8/bin/java -version

(needs 1-15 runs)


Bisecting confirms:

f13fb81ad3159543741e9132685335002a6d5df2 is the first bad commit
commit f13fb81ad3159543741e9132685335002a6d5df2
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Thu Mar 25 14:04:37 2021 -0300

    linux: Remove /proc/cpuinfo fallback on alpha and sparc

    There is no much gain in fallback to cpuinfo if sysfs is no present,
    usually on restricted environment neither will be present.  It also
    simplifies the code and make all architecture use the sched_getaffinity
    as the sysfs fallback.

    Checked on sparc64-linux-gnu.

 sysdeps/unix/sysv/linux/alpha/getsysstats.c | 38 -----------------------------
 sysdeps/unix/sysv/linux/getsysstats.c       | 22 +----------------
 sysdeps/unix/sysv/linux/sparc/getsysstats.c | 38 -----------------------------
 3 files changed, 1 insertion(+), 97 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/alpha/getsysstats.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/getsysstats.c
Comment 1 Adhemerval Zanella 2021-11-25 17:07:22 UTC
Fixed on 2.35.
Comment 2 Adhemerval Zanella 2021-11-25 17:07:35 UTC
I backported to 2.34 as well.
Comment 3 Florian Weimer 2021-11-26 11:40:54 UTC
Sorry, I didn't see this bug in time.

The bug here is that the /sys code returns a uniprocessor if /sys is not available. Then then /proc fallback is no longer needed.

A mounted /sys is more or less required these days.