Skip to content

tests: shuf: strace -e inject=getrandom:error=EAGAIN - #205

Closed
oech3 wants to merge 1 commit into
coreutils:masterfrom
oech3:patch-5
Closed

oech3 wants to merge 1 commit into
coreutils:masterfrom
oech3:patch-5

Conversation

@oech3

@oech3 oech3 commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@oech3

oech3 commented Feb 27, 2026

Copy link
Copy Markdown
Contributor Author

I prefer fallback in the case...

@pixelb

pixelb commented Feb 27, 2026

Copy link
Copy Markdown
Member

Just a general point on any commit.
In my experience the best format for change comments is

where: why...

what...
...

Comment thread tests/shuf/shuf.sh Resolved
Comment thread tests/shuf/shuf.sh Resolved
@oech3
oech3 marked this pull request as draft February 28, 2026 00:48
@oech3
oech3 marked this pull request as ready for review February 28, 2026 01:00
@pixelb

pixelb commented Feb 28, 2026

Copy link
Copy Markdown
Member

Better. Now we have to consider portability. The getrandom syscall was introduced in Linux 3.17.
gnulib documents getrandom as not being available in at least:
glibc 2.24, macOS 14, FreeBSD 11.0, NetBSD 9.3, OpenBSD 7.5, Minix 3.3, AIX 7.1, HP-UX 11.31, Solaris 11.0, Cygwin 1.7.x, mingw, MSVC 14, Android 8.1.

I see uu_shuf panics with this, so if testing graceful handling I suppose you could just check the return code is either 0 or 1.

Also EAGAIN could be problematic as conceivably implementations might retry with EAGAIN.
I checked uu_shuf also panics with EIO so probably best to use that

@oech3

oech3 commented Feb 28, 2026

Copy link
Copy Markdown
Contributor Author

Is ther any real situation that getrandom cause EIO (e.g. lacking entropy pool)?

@oech3

oech3 commented Feb 28, 2026

Copy link
Copy Markdown
Contributor Author

I think ENOSYS has some sense.

@pixelb

pixelb commented Feb 28, 2026

Copy link
Copy Markdown
Member

I think ENOSYS has some sense.

Right, but that doesn't panic with uutils and in fact uu_shuf falls back to /dev/urandom while GNU shuf does not.

@oech3

oech3 commented Feb 28, 2026

Copy link
Copy Markdown
Contributor Author

At tag/latest-commit, I see

> strace -o /dev/null -e inject=getrandom:error=ENOSYS shuf -i 1-9

thread 'main' (2731) panicked at /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/rand-0.9.2/src/rngs/thread.rs:124:17:
could not initialize ThreadRng: Function not implemented (os error 38)
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fish: Job 1, 'strace -o /dev/null -e inject=g…' terminated by signal SIGABRT (Abort)

@pixelb

pixelb commented Feb 28, 2026

Copy link
Copy Markdown
Member

Interesting uu_shuf 0.0.27 handled ENOSYS with the fallback

@pixelb

pixelb commented Feb 28, 2026

Copy link
Copy Markdown
Member

So ENOSYS is probably best then, and we can decide if fall back behavior is used in future

@oech3

This comment was marked as resolved.

Comment thread tests/shuf/shuf.sh Resolved
@pixelb

pixelb commented Feb 28, 2026

Copy link
Copy Markdown
Member

Pushed at 05443ce67

@pixelb pixelb closed this Feb 28, 2026
@oech3

This comment was marked as resolved.

hubot pushed a commit that referenced this pull request Feb 28, 2026
* tests/shuf/shuf.sh: Check we fail normally or succeed where
the getrandom syscall is not available.
#205
@oech3

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants