Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 931942 - sys-kernel/gentoo-sources-6.9.0 breaks sys-apps/yarn
Summary: sys-kernel/gentoo-sources-6.9.0 breaks sys-apps/yarn
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal
Assignee: Gentoo Kernel Bug Wranglers and Kernel Maintainers
URL:
Whiteboard: 6.9.2
Keywords: InVCS
Depends on:
Blocks:
 
Reported: 2024-05-15 09:40 UTC by Viktor Kuzmin
Modified: 2024-05-25 17:12 UTC (History)
10 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
config for 6.9.0 (config-6.9.0-gentoo,175.18 KB, text/plain)
2024-05-15 09:42 UTC, Viktor Kuzmin
Details
config for 6.8.9 (config-6.8.9-gentoo,174.21 KB, text/plain)
2024-05-15 09:42 UTC, Viktor Kuzmin
Details
6.8.9 strace log (6.8.9-strace.log.gz,143.81 KB, application/gzip)
2024-05-15 20:48 UTC, Andrew Udvare
Details
6.9.0 strace log (6.9.0-strace.log.gz,85.28 KB, application/gzip)
2024-05-15 20:48 UTC, Andrew Udvare
Details
Minimal example with yarn 1.x (yarn-test.tar.gz,243 bytes, application/gzip)
2024-05-18 08:03 UTC, Viktor Kuzmin
Details
Linux kernel patch for 6.9 (9999-yarn-issue.patch,435 bytes, patch)
2024-05-21 19:35 UTC, Andrew Udvare
Details | Diff
V2 kernel patch for 6.9 (9999-yarn-issue.patch,6.35 KB, patch)
2024-05-21 19:54 UTC, Andrew Udvare
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Viktor Kuzmin 2024-05-15 09:40:36 UTC
'yarn install' does not work properly after upgrading from gentoo-sources-6.8.9 to gentoo-sources-6.9.0:

It shows following error:
➤ YN0009: │ utf-8-validate@npm:5.0.10 couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-ddfcc0d8/build.log)
➤ YN0009: │ bufferutil@npm:4.0.7 couldn't be built successfully (exit code 1, logs can be found here: /tmp/xfs-7888b167/build.log)

And inside any such  build.log you can see:
# This file contains the result of Yarn building a package (utf-8-validate@npm:5.0.10)
# Script name: install

Error: spawn ETXTBSY
    at ChildProcess.spawn (node:internal/child_process:421:11)
    at Object.spawn (node:child_process:760:9)
    at zY (/home/kva/projects/kvaster/tamagui/.yarn/releases/yarn-4.1.0.cjs:9:51924)
    at NE.implementation (/home/kva/projects/kvaster/tamagui/.yarn/releases/yarn-4.1.0.cjs:159:1348)
    at NE.exec (/home/kva/projects/kvaster/tamagui/.yarn/releases/yarn-4.1.0.cjs:165:1414)
    at NE.run (/home/kva/projects/kvaster/tamagui/.yarn/releases/yarn-4.1.0.cjs:165:1585)
    at sce (/home/kva/projects/kvaster/tamagui/.yarn/releases/yarn-4.1.0.cjs:165:7428)
    at async yot (/home/kva/projects/kvaster/tamagui/.yarn/releases/yarn-4.1.0.cjs:167:16)
    at async u (/home/kva/projects/kvaster/tamagui/.yarn/releases/yarn-4.1.0.cjs:167:147)
    at async Eot (/home/kva/projects/kvaster/tamagui/.yarn/releases/yarn-4.1.0.cjs:168:14)

Reverting back to 6.8.9 (and earlier) fixes the problem.

Reproducible: Always

Steps to Reproduce:
1. Download yarn project (i.e. https://github.com/tamagui/tamagui)
2. Run 'yarn install'

Actual Results:  
yarn failed to install/build modules cause of spawn ETXTBSY error

Expected Results:  
On 6.8.9 and earlier it works without any problem

Important information: btrfs filesystem is used.

Portage 3.0.64 (python 3.11.9-final-0, default/linux/amd64/23.0/desktop/plasma, gcc-13, glibc-2.39-r6, 6.9.0-gentoo x86_64)
=================================================================
System uname: Linux-6.9.0-gentoo-x86_64-AMD_Ryzen_9_PRO_7940HS_w-_Radeon_780M_Graphics-with-glibc2.39
KiB Mem:    64523360 total,  52741032 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Wed, 15 May 2024 09:00:00 +0000
Head commit of repository gentoo: e06dcd300233970ef990eabe77bab1c6134e56fd

sh bash 5.2_p26-r3
ld GNU ld (Gentoo 2.42 p3) 2.42.0
distcc 3.4 x86_64-pc-linux-gnu [disabled]
ccache version 4.9.1 [disabled]
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.2_p26-r3::gentoo
dev-build/autoconf:        2.13-r8::gentoo, 2.72-r1::gentoo
dev-build/automake:        1.16.5-r2::gentoo
dev-build/cmake:           3.29.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-java/java-config:      2.3.3-r1::gentoo
dev-lang/perl:             5.38.2-r5::gentoo
dev-lang/python:           3.11.9::gentoo, 3.12.3::gentoo, 3.13.0_beta1_p1::gentoo
dev-lang/rust:             1.77.1::gentoo
dev-util/ccache:           4.9.1-r1::gentoo
sys-apps/baselayout:       2.15::gentoo
sys-apps/openrc:           0.54::gentoo
sys-apps/sandbox:          2.38::gentoo
sys-devel/binutils:        2.42-r1::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/clang:           17.0.6::gentoo, 18.1.5::gentoo
sys-devel/gcc:             13.2.1_p20240503::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-devel/lld:             17.0.6::gentoo, 18.1.5::gentoo
sys-devel/llvm:            17.0.6::gentoo, 18.1.5::gentoo
sys-kernel/linux-headers:  6.9::gentoo (virtual/os-headers)
sys-libs/glibc:            2.39-r6::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-verify-jobs: 1
    sync-rsync-extra-opts: 
    sync-rsync-verify-max-age: 3
    sync-rsync-verify-metamanifest: yes

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="*"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O3 -march=native -mtune=native -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/maven-bin-3.9/conf"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d"
CXXFLAGS="-O3 -march=native -mtune=native -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="-O3 -march=native -mtune=native -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 parallel-install 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="-O3 -march=native -mtune=native -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="ru_RU.utf8"
LC_ALL="ru_RU.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs"
LEX="flex"
LINGUAS="en ru"
MAKEOPTS="-j16"
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 a52 aac acl acpi activities alsa amd64 bluetooth branding bzip2 cairo cdda cdr cet cleartype crypt cups custom-optimization dbus declarative dri dri3 dts dvd dvdr elogind encode exif ffmpeg flac gdbm gif gpm gtk gui heif iconv icu ipv6 jpeg jumbo-build kde kwallet laptop lcms libnotify libtirpc lto mad mng mp3 mp4 mpeg multilib ncurses networkmanager nls nsplugin ogg opengl openmp pam pango pcre pdf pgo pipewire plasma png policykit ppds pulseaudio qml qt5 readline samba screencast sdl seccomp sound spell ssl startup-notification svg test-rust tiff touchpad truetype udev udisks unicode upower usb v4l2 vaapi vdpau vorbis vulkan wayland widgets wxwidgets x264 xattr xcb xft xml xv xvid zlib zsh-completion" ABI_X86="64" 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" CPU_FLAGS_X86="aes avx avx2 avx512_bf16 avx512_bitalg avx512_vbmi2 avx512_vnni avx512_vpopcntdq avx512bw avx512cd avx512dq avx512f avx512ifma avx512vbmi avx512vl f16c fma3 mmx mmxext pclmul popcnt rdrand sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 vpclmulqdq" 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="keyboard mouse wacom libinput synaptics" KERNEL="linux" L10N="en ru" 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="ruby32" SANE_BACKENDS="epson2" VIDEO_CARDS="amdgpu radeonsi" 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, LD, LFLAGS, LIBTOOL, 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
Comment 1 Viktor Kuzmin 2024-05-15 09:42:41 UTC
Created attachment 892959 [details]
config for 6.9.0
Comment 2 Viktor Kuzmin 2024-05-15 09:42:58 UTC
Created attachment 892960 [details]
config for 6.8.9
Comment 3 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-05-15 10:39:59 UTC
Could you (or tatsh, cc'd) please try:
a) biect (and report upstream);
b) construct a smaller reproducer?
Comment 4 Andrew Udvare 2024-05-15 20:47:41 UTC
The normal case is that a forgotten fclose() followed by an operation like execve() will cause this error, but I am fairly certain that is not the case here, unless the kernel is actually the one failing to close the file. I wrote a very simple C program to test this and nothing unusual happens. So I think it has to do with timing between the subprocesses or threads. (See the strace logs.)

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>

char *ARGS[] = {
    "node",
    "/home/tatsh/whatever/tsc",
    "--help",
};
char TEMP_PREFIX[] = "/tmp/yarn-XXXXXX";

int main(int argc, char *argv[]) {
    char *tempdir = mkdtemp(TEMP_PREFIX);
    if (!tempdir) {
        printf("Error: %d\n", errno);
        return 1;
    }
    char name[255];
    memset(name, 0, 255);
    snprintf(name, 255, "%s/node", tempdir);
    FILE *f = fopen(name, "w");
    fwrite("#!/bin/sh\n\nexec \"/usr/bin/node\" \"$@\"\n", 37, 1, f);
    fclose(f);
    chmod(name, 0755);
    if (execve(name, ARGS, NULL) < 0) {
        printf("Error: %d\n", errno);
        return 1;
    }
    return 0;
}

Note that libuv in our Node package is dev-libs/libuv.

Yarn 1.x theoretical trace from fs.chmod to the syscall (in order):

executeLifecycleScript():
https://github.com/yarnpkg/yarn/blob/158d96dce95313d9a00218302631cd263877d164/src/util/execute-lifecycle-script.js#L356C11-L356C33

asyncFs.chmod()
https://github.com/yarnpkg/yarn/blob/158d96dce95313d9a00218302631cd263877d164/src/util/portable-script.js#L50

Chmod()
https://github.com/nodejs/node/blob/28b0a5826b3474deebe423850924568b2d1082d7/src/node_file.cc#L2627

SyncCallAndThrowIf():
https://github.com/nodejs/node/blob/28b0a5826b3474deebe423850924568b2d1082d7/src/node_file-inl.h#L360

uv_fs_chmod():
https://github.com/libuv/libuv/blob/bf61390769068de603e6deec8e16623efcbe761a/src/unix/fs.c#L1787

POST macro calling uv__fs_work():
https://github.com/libuv/libuv/blob/bf61390769068de603e6deec8e16623efcbe761a/src/unix/fs.c#L151

uv__fs_work() actual chmod() glibc call:
https://github.com/libuv/libuv/blob/bf61390769068de603e6deec8e16623efcbe761a/src/unix/fs.c#L1697C14-L1697C19

This is important to look at because chmod("/tmp/yarn--.../node", 0755) should be the last operation on the 'portable proxy' script.
Comment 5 Andrew Udvare 2024-05-15 20:48:11 UTC
Created attachment 893032 [details]
6.8.9 strace log
Comment 6 Andrew Udvare 2024-05-15 20:48:23 UTC
Created attachment 893033 [details]
6.9.0 strace log
Comment 7 Viktor Kuzmin 2024-05-18 07:38:35 UTC
Small comments: the test was done with latest yarn, not with 1.x

p.s.: I'm trying to do a bisect to detect breaking change
Comment 8 Viktor Kuzmin 2024-05-18 08:03:37 UTC
Created attachment 893300 [details]
Minimal example with yarn 1.x

Attached minimal example with yarn 1.x.

Running 'yarn install' results in:

yarn install v1.22.22
warning package.json: No license field
info No lockfile found.
warning rentway@1.0.0: No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
error /home/kva/projects/kvaster/yarn-test/node_modules/core-js: Command failed.
Exit code: 126
Command: node -e "try{require('./postinstall')}catch(e){}"
Arguments: 
Directory: /home/kva/projects/kvaster/yarn-test/node_modules/core-js
Output:
/bin/sh: /tmp/yarn--1716019239138-0.21101994278402847/node: /bin/sh: bad interpreter: Text file busy
Comment 9 Andrew Udvare 2024-05-18 09:24:02 UTC
Modern Yarn has the same issue as 1.x. I would imagine that part of the code has not changed much.
Comment 10 Viktor Kuzmin 2024-05-19 05:33:46 UTC
The question is if this problem is yarn related or kernel related. Today I'm going to do a kernel bisect test...
Comment 11 Viktor Kuzmin 2024-05-21 14:23:42 UTC
I've made kernel bisect.

the last good commit: 2708af1adc11700c6c3ce4109e3b133079a36a78
the first bad commit: af5d68f8892f8ee8f137648b79ceb2abc153a19b

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=af5d68f8892f8ee8f137648b79ceb2abc153a19b
Comment 12 Andrew Udvare 2024-05-21 15:35:32 UTC
I also confirmed with bisect it is af5d68f8892f8ee8f137648b79ceb2abc153a19b
Comment 14 Andrew Udvare 2024-05-21 19:35:45 UTC
Created attachment 893681 [details, diff]
Linux kernel patch for 6.9

https://lore.kernel.org/io-uring/40c7404a-f4ce-4a7d-86f3-313a9e9ee113@kernel.dk/
Comment 15 Viktor Kuzmin 2024-05-21 19:38:02 UTC
Already applyed and tested - it's all working good with the patch.
Comment 16 Andrew Udvare 2024-05-21 19:54:31 UTC
Created attachment 893682 [details, diff]
V2 kernel patch for 6.9
Comment 17 Mike Pagano gentoo-dev 2024-05-22 18:30:09 UTC
(In reply to Andrew Udvare from comment #16)
> Created attachment 893682 [details, diff] [details, diff]
> V2 kernel patch for 6.9

Do we only need V2 ?
Comment 18 kfm 2024-05-23 00:19:08 UTC
(In reply to Mike Pagano from comment #17)
> Do we only need V2 ?

Yes.
Comment 19 Mike Pagano gentoo-dev 2024-05-23 12:42:37 UTC
Queued for next release of the 6.9 kernel
Comment 20 Larry the Git Cow gentoo-dev 2024-05-25 17:12:25 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c864fa08ab8a89092c9be07bfd2e9f40a37bc569

commit c864fa08ab8a89092c9be07bfd2e9f40a37bc569
Author:     Mike Pagano <mpagano@gentoo.org>
AuthorDate: 2024-05-25 17:11:26 +0000
Commit:     Mike Pagano <mpagano@gentoo.org>
CommitDate: 2024-05-25 17:11:26 +0000

    sys-kernel/gentoo-sources: add 6.9.2,io_uring/sqpool fix
    
    Closes: https://bugs.gentoo.org/931942
    
    Signed-off-by: Mike Pagano <mpagano@gentoo.org>

 sys-kernel/gentoo-sources/Manifest                 |  3 +++
 .../gentoo-sources/gentoo-sources-6.9.2.ebuild     | 27 ++++++++++++++++++++++
 2 files changed, 30 insertions(+)