OpenRC / openrc

The OpenRC init system
BSD 2-Clause "Simplified" License
1.45k stars 246 forks source link

checkpath: cannot stat /run: value too large for datatype #704

Closed timw4mail closed 4 months ago

timw4mail commented 4 months ago

First things first: this is an edge case on 486-era hardware. I would like suggestions for a workaround, but I understand that there might be little reason for a source 'fix'.

With that out of the way, I'm trying to set up Gentoo with OpenRC for testing a cpu identification program on 486 and Pentium level hardware.

On most Pentium-level hardware, OpenRC loads without issue.

On the 486-platform Pentium Overdrive (Pentium in 486 socket), and other 486 chips, OpenRC doesn't load, but errors out after mounting /run.

I get these errors:

checkpath: /run/openrc: unable to stat run: Value too large for defined datatype
checkpath: /run/lock: unable to stat run: Value too large for defined datatype
/lib/rc/sh/init.sh: line 102: /run/openrc/softlevel: No such file or directory

I've tried compiling OpenRC with -Os and -O2 level optimizations, neither made a difference. I've also tried versions 0.54, 0.53.1, and 0.48.

thesamesam commented 4 months ago

Now, this is interesting, because we definitely should be building with LFS. But... Meson actually does that for us (rightly or wrongly).

Did you build using muon?

cc @eli-schwartz

eli-schwartz commented 4 months ago

Ref. https://github.com/annacrombie/muon/pull/20#issuecomment-1986922001

timw4mail commented 4 months ago

From what I can see, Gentoo uses meson in the build script.

thesamesam commented 4 months ago

Can you try to grab the build.log from the build please? ebuild /path/to/ebuild clean install then grab the build.log from /var/tmp/portage? Thanks.

timw4mail commented 4 months ago

I'll add that as soon as I can.

timw4mail commented 4 months ago

Build.log (sorry about the color codes)

https://gist.github.com/timw4mail/46deb495542a2093d367cf3630729e5a

thesamesam commented 4 months ago

I don't get it yet... src/checkpath/checkpath.c does nothing abnormal at a glance and the file was built with -D_FILE_OFFSET_BITS=64:

[12/203] i486-pc-linux-gnu-gcc -Isrc/checkpath/checkpath.p -Isrc/checkpath -I../openrc-0.54/src/checkpath -Isrc/shared -I../openrc-0.54/src/shared -Isrc/libeinfo -I../openrc-0.54/src/libeinfo -Isrc/librc -I../openrc-0.54/src/librc -I/usr/include/security -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Wpedantic -std=c99 -D_DEFAULT_SOURCE -Wcast-align -Wcast-qual -Wdeclaration-after-statement -Wformat=2 -Winline -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wsequence-point -Wshadow -Wwrite-strings -Werror=implicit-int -Werror=implicit-function-declaration -Werror=int-conversion -DHAVE_MALLOC_EXTENDED_ATTRIBUTE -DHAVE_CLOSE_RANGE -DHAVE_STRLCPY -O2 -march=i486 -pipe '-DBRANDING="Gentoo Linux"' -DHAVE_PAM -MD -MQ src/checkpath/checkpath.p/checkpath.c.o -MF src/checkpath/checkpath.p/checkpath.c.o.d -o src/checkpath/checkpath.p/checkpath.c.o -c ../openrc-0.54/src/checkpath/checkpath.c

It's aborting at https://github.com/OpenRC/openrc/blob/3d30b6fddaf92c612deea88d2ced7114ed1fcf9c/src/checkpath/checkpath.c#L116.

thesamesam commented 4 months ago

Could you share emerge --info too please?

timw4mail commented 4 months ago

Portage 3.0.63 (python 3.11.9-final-0, default/linux/x86/23.0/i486, gcc-13, glibc-2.38-r13, 4.19.313max i586)

System uname: Linux-4.19.313max-i586-05-00-with-glibc2.38 KiB Mem: 510548 total, 386032 free KiB Swap: 1048572 total, 1048572 free Timestamp of repository gentoo: Tue, 07 May 2024 10:30:00 +0000 Head commit of repository gentoo: 265232ddded44253bd45458b1c50bde1c3f84924 Timestamp of repository guru: Tue, 07 May 2024 08:05:58 +0000 Head commit of repository guru: de07e4353531d5e6d221c394c81f56fe682bb82e

sh bash 5.1_p16-r6 ld GNU ld (Gentoo 2.41 p5) 2.41.0 app-misc/pax-utils: 1.3.7::gentoo app-shells/bash: 5.1_p16-r6::gentoo dev-build/autoconf: 2.71-r7::gentoo dev-build/automake: 1.16.5-r2::gentoo dev-build/cmake: 3.28.3::gentoo dev-build/libtool: 2.4.7-r4::gentoo dev-build/make: 4.4.1-r1::gentoo dev-build/meson: 1.4.0-r1::gentoo dev-lang/perl: 5.38.2-r3::gentoo dev-lang/python: 3.11.9::gentoo, 3.12.3::gentoo sys-apps/baselayout: 2.15::gentoo sys-apps/openrc: 0.54::gentoo sys-apps/sandbox: 2.38::gentoo sys-devel/binutils: 2.41-r5::gentoo sys-devel/binutils-config: 5.5::gentoo sys-devel/gcc: 13.2.1_p20240210::gentoo sys-devel/gcc-config: 2.11::gentoo sys-kernel/linux-headers: 6.6-r1::gentoo (virtual/os-headers) sys-libs/glibc: 2.38-r13::gentoo Repositories:

gentoo location: /var/db/repos/gentoo sync-type: rsync sync-uri: rsync://rsync.gentoo.org/gentoo-portage priority: -1000 volatile: False sync-rsync-extra-opts: sync-rsync-verify-metamanifest: yes sync-rsync-verify-jobs: 1 sync-rsync-verify-max-age: 3

guru location: /var/db/repos/guru sync-type: git sync-uri: https://github.com/gentoo-mirror/guru.git masters: gentoo volatile: False

Binary Repositories:

gentoobinhost priority: 1 sync-uri: https://gentoo.osuosl.org/releases/x86/binpackages/23.0/i486

ACCEPT_KEYWORDS="x86" ACCEPT_LICENSE="*" CBUILD="i486-pc-linux-gnu" CFLAGS="-O2 -march=i486 -pipe" CHOST="i486-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d" CXXFLAGS="-O2 -march=i486 -pipe" DISTDIR="/var/cache/distfiles" ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME" FCFLAGS="-O2 -march=i486 -pipe" FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync merge-wait multilib-strict network-sandbox news parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr" FFLAGS="-O2 -march=i486 -pipe" GENTOO_MIRRORS="http://distfiles.gentoo.org" LANG="en_US.utf8" LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs" LEX="flex" MAKEOPTS="-j9 -l9" PKGDIR="/var/cache/binpkgs" PORTAGE_CONFIGROOT="/" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git" PORTAGE_TMPDIR="/var/tmp" SHELL="/bin/zsh" USE="X acl bzip2 crypt fbcon gdbm iconv ipv6 libtirpc ncurses openmp pam pcre readline seccomp ssl test-rust unicode x86 xattr zlib" ABI_X86="32" ADA_TARGET="gcc_12" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_anon authn_dbm authn_file authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir env expires ext_filter file_cache filter headers include info log_config logio mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 ntrip navcom oceanserver oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 tsip tripmate tnt ublox" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz glk hd44780 lb216 lcdm001 mtxorb text" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-1" POSTGRES_TARGETS="postgres15" PYTHON_SINGLE_TARGET="python3_11" PYTHON_TARGETS="python3_11" RUBY_TARGETS="ruby31" VIDEO_CARDS="r128 fbdev vesa mga via" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2p iface geoip fuzzy condition tarpit sysrq proto logmark ipmark dhcpmac delude chaos account" Unset: ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EMERGE_DEFAULT_OPTS, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS

ceamac commented 4 months ago

Maybe glibc lacks support for 64 bit offsets on i486?

How large is the root filesystem? Try ls -lid /run, is that a huge number?

thesamesam commented 4 months ago

It's possible it's i486-specific but it'll be a bug in glibc if so, if _FILE_OFFSET_BITS doesn't work. Note that this can also happen on large inode size (ino_t).

The problem is setting up a test env is a pain. You can do it with tmpfs but you need to force it to use up all the 32-bit inodes numbers first.

timw4mail commented 4 months ago

Maybe glibc lacks support for 64 bit offsets on i486?

How large is the root filesystem? Try ls -lid /run, is that a huge number?

The root filesystem is 12GB, on ext4.

From ls -lid /run, the largest number I see is 420.

thesamesam commented 4 months ago

Oh, this is kind of more interesting if we're on ext4, as I don't think it ever has such large inodes (might be wrong). Is your clock right? (What's the value of date and date -u?)

timw4mail commented 4 months ago

Hmm...so apparently the 486 isn't Y2k-compliant. Any date beyond 1999 and it shows 2094! I set the date to 1999, and the same behavior appears.

I likely have another 486 system that is Y2K compliant, so I'll give that a try.

thesamesam commented 4 months ago

time_t is 32-bit on these systems and will overflow in Y2038. You can request 64-bit time_t but it's an ABI break. We're working on the transition in Gentoo (https://wiki.gentoo.org/wiki/Project:Toolchain/time64_migration).

But overflowing beyond 1999 is curious and I'm drawing a blank right now. I will ask around...

thesamesam commented 4 months ago

dwfreed suggested a theory that coincides with yours - something like the system RTC not being Y2K compliant and Linux handling it terribly..

You could try disabling the hwclock to test this?

timw4mail commented 4 months ago

So I'm able to get OpenRC running on a Y2K-compliant 486 system, so I think the clock time was the issue. I've never heard of a date causing such a fundamental issue, but I'm glad to have solved this silly mystery.