rust-lang / rust-lang/rust

fatal runtime error: assertion failed: output.write(&bytes).is_ok()

Open
#125,952 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug E-needs-mcve O-NixOS T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

So I was recompiling a typescript nextjs project in a nix derivation, that previously worked (Nix builds are kind of reproducible, so that's very unexpected) and it failed with a weird error:

guardian-ui> @fedimint/types:build: cache miss, executing a873a14720ccc5d2
guardian-ui>  WARNING  passwd database shell="/noshell" which is not executable (ENOENT: No such file or directory), falling back to /bin/sh
guardian-ui> @fedimint/types:build: fatal runtime error: assertion failed: output.write(&bytes).is_ok()
guardian-ui> @fedimint/types:build:
guardian-ui>  Tasks:    0 successful, 1 total
guardian-ui> Cached:    0 cached, 1 total
guardian-ui>   Time:    1.095s

I suspect my kernel version might be different because I just upgraded to NixOS 24.05 recently.

I traced this panic to https://github.com/rust-lang/rust/blob/1689a5a531f1fe404944ed8c3ac6cb85a2cff7e0/library/std/src/sys/pal/unix/process/process_unix.rs#L125

I got a strace output:

guardian-ui> [pid   675] setsid()                    = 675
guardian-ui> [pid   675] ioctl(0, TIOCSCTTY, 0)      = 0
guardian-ui> [pid   675] open("/dev/fd", O_RDONLY|O_LARGEFILE|O_CLOEXEC|O_DIRECTORY) = 17
guardian-ui> [pid   675] fcntl(17, F_SETFD, FD_CLOEXEC) = 0
guardian-ui> [pid   675] getdents64(17, 0x7ffff7b2f4b8 /* 22 entries */, 2048) = 528
guardian-ui> [pid   675] getdents64(17, 0x7ffff7b2f4b8 /* 0 entries */, 2048) = 0
guardian-ui> [pid   675] close(5)                    = 0                                                                                   (6 results) 20:25:45 [2127/32726]
guardian-ui> [pid   675] close(6)                    = 0
guardian-ui> [pid   675] close(7)                    = 0
guardian-ui> [pid   675] close(8)                    = 0
guardian-ui> [pid   675] close(9)                    = 0
guardian-ui> [pid   675] close(10)                   = 0
guardian-ui> [pid   675] close(11)                   = 0
guardian-ui> [pid   675] close(12)                   = 0
guardian-ui> [pid   675] close(13)                   = 0
guardian-ui> [pid   675] close(14)                   = 0
guardian-ui> [pid   675] close(15)                   = 0
guardian-ui> [pid   675] close(16)                   = 0
guardian-ui> [pid   675] close(17)                   = -1 EBADF (Bad file descriptor)
guardian-ui> [pid   675] close(18)                   = 0
guardian-ui> [pid   601] <... recvfrom resumed>"", 8, 0, NULL, NULL) = 0
guardian-ui> [pid   675] close(24 <unfinished ...>
guardian-ui> [pid   601] close(17 <unfinished ...>
guardian-ui> [pid   675] <... close resumed>)        = 0
guardian-ui> [pid   675] execve("/build/yarn--1717471544555-0.05173506673993855/yarn", ["/build/yarn--1717471544555-0.051"..., "run", "build"], 0x7ffff7e5b1a0 /* 135 vars *
/ <unfinished ...>
guardian-ui> [pid   601] <... close resumed>)        = 0
guardian-ui> [pid   675] <... execve resumed>)       = -1 ETXTBSY (Text file busy)
guardian-ui> [pid   675] write(18, "\0\0\0\32NOEX", 8) = -1 EBADF (Bad file descriptor)
guardian-ui> [pid   675] write(2, "fatal runtime error: assertion f"..., 68) = 68
guardian-ui> [pid   675] rt_sigprocmask(SIG_BLOCK, ~[RTMIN RT_1 RT_2], [], 8) = 0
guardian-ui> [pid   675] tkill(675, SIGABRT)         = 0
guardian-ui> [pid   675] rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
guardian-ui> [pid   675] --- SIGABRT {si_signo=SIGABRT, si_code=SI_TKILL, si_pid=675, si_uid=1000} ---
guardian-ui> [pid   601] close(14)                   = 0
guardian-ui> [pid   601] close(15)                   = 0
guardian-ui> [pid   601] close(16)                   = 0
guardian-ui> [pid   601] fcntl(11, F_DUPFD_CLOEXEC, 0) = 14
guardian-ui> [pid   601] fcntl(14, F_SETFD, FD_CLOEXEC) = 0
guardian-ui> [pid   601] fcntl(11, F_DUPFD_CLOEXEC, 0) = 15
guardian-ui> [pid   601] fcntl(15, F_SETFD, FD_CLOEXEC) = 0

I'm not sure where to even report it, and a bit tired to dig deeper. Creating the issue just for reference.

The whole thing can be reproduced with:

nix build 'github:fedimint/ui?rev=1fc0cc6322f4ebb0f0854cd870b79c9971ff4b34#guardian-ui'

I'm going to try it on some machines and see when it fails and when works.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the provided nix build command and compare the strace output with library/std/src/sys/pal/unix/process/process_unix.rs at the linked assertion. Focus on the ETXTBSY execve failure followed by the EBADF write; done means the failure is characterized and the runtime no longer aborts unexpectedly or the issue is routed to the responsible component.

Written by the indexing model from the issue text.

Assessment

Tech stack
nextjs, nixos, rust, typescript
Domain
operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.