0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-18 16:10:19 +03:00
nixpkgs/nixos/lib
Yarny0 5e2baf54d4 nixos/test-driver: fix race from filename clash in OCR
There is a race condition
in the new paralleized OCR code.
The race condition got "active" in commit
819d304a39 (Use futures for OCR parallelization),
however, the underlying bug already slipped in with commit
e6ea13f4ea (User proper `Path` instead of `str` in OCR code).

The OCR module applies tesseract to at most three variants
of the screenshot: the original one, and two variants that
are created by a preprocessing step (with ImageMagick).
The preprocessing step needs an output filename
that is used to write the preprocessed image file.

The "Path" commit broke the way the output file is named:
The code still attempts to append a ".negative" to *one*
of the preprocessed output files, but the method
`.with_suffix` is not suitable for that purpose:
Lateron, ".png" is also added with `.with_suffix`,
*replacing* the ".negative" and thereby yielding the
*the same* output filename for both preprocessed files.

Without parallelization, this doesn't hurt;
preprocessed files are simply created and analyzed in order.
But the parallelization commit
causes that these two tasks now run in parallel
(plus the third task that analyses the original screensshot,
but that does not cause any further harm here):

* Task 1: preprocess (non-negative), then tesseract the output
* Task 2: preprocess (negative), then tesseract the output

Both tasks use the same filename and thus the same file for the
preprocessed image that is generated, then used by tesseract.
This often creates a garbage file since both
preprocessings write that one file at the same time.
Tesseract consequently fails and
complains about bad data in its input file.

The commit at hand simply fixes the file naming
by adding ".negative.png" or ".positive.png"
to the filename for the preprocessed image.
This ensures both threads no longer hurt each
other's data and can now coexist in peace.
2025-07-04 12:10:53 +02:00
..
make-options-doc treewide: fix typos 2025-06-02 16:07:07 +02:00
test-driver nixos/test-driver: fix race from filename clash in OCR 2025-07-04 12:10:53 +02:00
testing Revert "treewide: migrate nixos modules to networking.hosts" 2025-06-09 00:10:05 +05:30
default.nix treewide: format all inactive Nix files 2024-12-10 20:26:33 +01:00
eval-cacheable-options.nix treewide: format all inactive Nix files 2024-12-10 20:26:33 +01:00
eval-config-minimal.nix treewide: format all inactive Nix files 2024-12-10 20:26:33 +01:00
eval-config.nix treewide: Format all Nix files 2025-04-01 20:10:43 +02:00
from-env.nix treewide: format all inactive Nix files 2024-12-10 20:26:33 +01:00
make-btrfs-fs.nix treewide: Format all Nix files 2025-04-01 20:10:43 +02:00
make-channel.nix treewide: format all inactive Nix files 2024-12-10 20:26:33 +01:00
make-disk-image.nix nixosTests.limine.bios: init 2025-05-26 14:06:42 +05:30
make-ext4-fs.nix make-ext4-fs: enable parallel compression for zstd 2024-12-13 00:39:12 +07:00
make-iso9660-image.nix treewide: format all inactive Nix files 2024-12-10 20:26:33 +01:00
make-iso9660-image.sh
make-multi-disk-zfs-image.nix nixos/lib/make-*-disk-zfs-image: fix build 2025-02-02 21:51:07 +01:00
make-single-disk-zfs-image.nix nixos/lib/make-*-disk-zfs-image: fix build 2025-02-02 21:51:07 +01:00
make-squashfs.nix nixos: make squashfs reproducible 2025-05-30 11:34:05 +05:30
make-system-tarball.nix treewide: format all inactive Nix files 2024-12-10 20:26:33 +01:00
make-system-tarball.sh treewide: load structured attributes in all bash builders consistently 2024-12-29 18:36:47 +01:00
qemu-common.nix treewide: format all inactive Nix files 2024-12-10 20:26:33 +01:00
systemd-lib.nix treewide: Format all Nix files 2025-04-01 20:10:43 +02:00
systemd-network-units.nix treewide: format all inactive Nix files 2024-12-10 20:26:33 +01:00
systemd-types.nix treewide: format all inactive Nix files 2024-12-10 20:26:33 +01:00
systemd-unit-options.nix nixos/unitOption: remove unnecessary definition filtering 2025-05-30 22:39:51 +02:00
test-script-prepend.py nixos/test-driver: integrate Python unittest assertions 2025-03-20 12:30:58 +00:00
testing-python.nix nixos/test-driver: printout instructions on how to connect via AF_VSOCK 2025-05-08 10:51:39 +02:00
utils.nix fix(utils): remove unnecessary $ from variable in arithmetic 2025-02-08 23:07:10 -05:00