Repository navigation
Description
The following code:
Lines 294 to 298 in 5ce627b
| // Release the implicit job token for this process while NASM is running. | |
| // Without this, the maximum number of NASM processes would be (NUM_JOBS - 1). | |
| // This would mean that a build process with NUM_JOBS=1 would have | |
| // no tokens left for NASM to run, causing the build to stall. | |
| jobserver.release_raw().unwrap(); |
releases a jobserver token that was never acquired by nasm-rs. This is a violation of jobserver, and it is not behaving correctly with token-accounting jobserver implementations such as steve or guildmaster. In the case of steve, the attempt to write an additional token yields ENOSPC, causing unwrap() to terminate the program:
Running `/var/tmp/portage/media-video/rav1e-0.8.1/work/rav1e-0.8.1/target/release/build/rav1e-2f7717166fc5a2d9/build-script-build`
error: failed to run custom build command for `rav1e v0.8.1 (/var/tmp/portage/media-video/rav1e-0.8.1/work/rav1e-0.8.1)`
Caused by:
process didn't exit successfully: `/var/tmp/portage/media-video/rav1e-0.8.1/work/rav1e-0.8.1/target/release/build/rav1e-2f7717166fc5a2d9/build-script-build` (exit status: 101)
--- stdout
cargo:rustc-cfg=nasm_x86_64
--- stderr
thread 'main' (1757) panicked at /var/tmp/portage/media-video/rav1e-0.8.1/work/cargo_home/gentoo/nasm-rs-0.3.0/src/lib.rs:296:33:
called `Result::unwrap()` on an `Err` value: Os { code: 28, kind: StorageFull, message: "No space left on device" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
In the case of GM, the additional "released" token will be ignored, and then the attempt to reacquire it will acquire another token (that will be released with a warning upon program termination):
Lines 319 to 320 in 5ce627b
| // Reacquire the implicit job token (see comments above for more info). | |
| jobserver.acquire_raw().expect("Failed to reacquire implicit token"); |
My understanding is that this code is responsible for handling the "implicit slot" akin to GNU Make's. I'm afraid that such a hack is not workable per the protocol, and you need to handle such a slot locally rather than deferring that to the jobserver.
Credits to @amonakov who found the problematic code.
Activity
FreezyLemon commentedon Dec 18, 2025
@medek if you haven't started on this yet, i could also attempt to solve this?
medek commentedon Dec 18, 2025
@FreezyLemon nearly done, should be to push code tonight/tomorrow.
Fix for issue #44.
medek commentedon Jan 13, 2026
Well that was a lie.
RwLock implementation fix.
It works but not really checking if a lock gets poisoned properly. Would have liked to use std::sync::nonpoison but it's a nightly only feature right now.
I also played around with a lock free version. It introduces unsafe code to the library though...
Fix for issue #44. (#46)