13
45
Fork
You've already forked fibers
10

preemption does not work on the Hurd #171

Open
opened 2026年02月15日 13:44:42 +01:00 by Yelninei · 2 comments

Forwarding guix/guix#2471

The test tests/preemption.scm specifically the

;; assert run-fibers on (race-until 100) terminates
(assert-run-fibers-returns (100) (race-until 100))

never terminates when running the tests on the Hurd causing the tests to hang.

The reason is that in with-interrupts/thread-cputime the interrupt-thread calls clock-nanosleep with a clock from pthread-getcpuclockid which fails with EINVAL.

The exception gets caught by the false-if-exception and the interrupt-thread just dies.

Then in the test the expected interrupt never happens and the test runs forever.

Forwarding https://codeberg.org/guix/guix/issues/2471 The test `tests/preemption.scm` specifically the ``` ;; assert run-fibers on (race-until 100) terminates (assert-run-fibers-returns (100) (race-until 100)) ``` never terminates when running the tests on the Hurd causing the tests to hang. The reason is that in `with-interrupts/thread-cputime` the `interrupt-thread` calls `clock-nanosleep` with a clock from `pthread-getcpuclockid` which fails with EINVAL. The exception gets caught by the `false-if-exception` and the `interrupt-thread` just dies. Then in the test the expected interrupt never happens and the test runs forever.

I can reproduce the problem on x86_64-gnu from Guix commit f0e22ae62c143fbf00bde368c2adbc848cff5ff5:

ludo@childhurd ~$ guile -L /gnu/store/*-fibers*/share/guile/site/3.0 --no-auto-compile
GNU Guile 3.0.11
Copyright (C) 1995-2024 Free Software Foundation, Inc.
Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.
Enter `,help' for help.
scheme@(guile-user)> ,use(fibers posix-clocks)
scheme@(guile-user)> (pthread-getcpuclockid (pthread-self))
1ドル = 3
scheme@(guile-user)> (clock-nanosleep 1ドル 1000000)
ice-9/boot-9.scm:1705:22: In procedure raise-exception:
Invalid argument

The value returned above is CLOCK_THREAD_CPUTIME_ID.

Currently, in glibc, mach/clock_nanosleep.c reads:

int
__clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
		 struct timespec *rem)
{
 if ((clock_id != CLOCK_REALTIME && clock_id != CLOCK_MONOTONIC)
 || req->tv_sec < 0
 || !valid_nanoseconds (req->tv_nsec)
 || (flags != 0 && flags != TIMER_ABSTIME))
 return EINVAL;
I can reproduce the problem on x86_64-gnu from Guix commit f0e22ae62c143fbf00bde368c2adbc848cff5ff5: ``` ludo@childhurd ~$ guile -L /gnu/store/*-fibers*/share/guile/site/3.0 --no-auto-compile GNU Guile 3.0.11 Copyright (C) 1995-2024 Free Software Foundation, Inc. Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'. This program is free software, and you are welcome to redistribute it under certain conditions; type `,show c' for details. Enter `,help' for help. scheme@(guile-user)> ,use(fibers posix-clocks) scheme@(guile-user)> (pthread-getcpuclockid (pthread-self)) 1ドル = 3 scheme@(guile-user)> (clock-nanosleep 1ドル 1000000) ice-9/boot-9.scm:1705:22: In procedure raise-exception: Invalid argument ``` The value returned above is `CLOCK_THREAD_CPUTIME_ID`. Currently, in glibc, `mach/clock_nanosleep.c` reads: ```c int __clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req, struct timespec *rem) { if ((clock_id != CLOCK_REALTIME && clock_id != CLOCK_MONOTONIC) || req->tv_sec < 0 || !valid_nanoseconds (req->tv_nsec) || (flags != 0 && flags != TIMER_ABSTIME)) return EINVAL; ```

@janneke mentioned on irc that he experienced dynamic-wind* test crash inconsistently on 1.4.3 although I got no problems with that currently.

Signals delivery fails constantly at GC # 189
Signals delivery fails constantly
/gnu/store/d367xck1ml092xgcr95p17dbmfq008h7-bash-minimal-5.2.37/bin/bash: line 6: 13661 Aborted > (core dumped) top_srcdir="/tmp/guix-build-guile-fibers-1.4.3.drv-0/source" ./env /gnu/store/> kg0v4mrk6748xnvba4rbri3di8px4pvg-guile-3.0.9/bin/guile --no-auto-compile -s ${dir}$tst

it looks similar to the crash in #175 (comment) with the "fix".

@janneke mentioned on irc that he experienced `dynamic-wind*` test crash inconsistently on 1.4.3 although I got no problems with that currently. > <janneke> Signals delivery fails constantly at GC # 189 > <janneke> Signals delivery fails constantly > <janneke> /gnu/store/d367xck1ml092xgcr95p17dbmfq008h7-bash-minimal-5.2.37/bin/bash: line 6: 13661 Aborted > (core dumped) top_srcdir="/tmp/guix-build-guile-fibers-1.4.3.drv-0/source" ./env /gnu/store/> kg0v4mrk6748xnvba4rbri3di8px4pvg-guile-3.0.9/bin/guile --no-auto-compile -s ${dir}$tst it looks similar to the crash in https://codeberg.org/guile/fibers/pulls/175#issuecomment-12659694 with the "fix".
Sign in to join this conversation.
No Branch/Tag specified
main
revert-110-wip-cancel-timer-operations
fdless-draft
pr-60-adjust
more-operations
timer-wheel
cross
nice-dynamic-wind-experiment
v1.4.3
v1.4.2
v1.4.1
v1.4.0
v1.3.1
v1.3.0
v1.2.0
v1.1.1
v1.1.0
v1.0.0
v0.5.0
v0.4.0
v0.3.0
v0.2.0
v0.1.0
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
guile/fibers#171
Reference in a new issue
guile/fibers
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?