Files
photocraft/crates/engine/tests
dotCooCoo 2f797ddea3 Print: list printers and spool from one thread at a time
On Windows 11 (winspool.drv 10.0.26100.9444) the custom_print_paper
test binary died with STATUS_ACCESS_VIOLATION. Its three tests open
the Print dialog at once, and each one lists printers: file.printers
calls craft_print::printers(), which opens each printer's PrintTicket
provider (PTOpenProvider). winspool creates a process-wide cache
without a lock the first time PTOpenProvider is called for a printer
whose provider is PrintConfig.dll. When two threads do this together,
winspool can leave its pointer to the cache on a freed object, and the
next caller enters that object's deleted critical section. The app can
make the same calls from two threads: the Print dialog on the UI
thread and a print job's worker.

print_cmds::with_spooler holds a process-wide lock around every call
PhotoCraft makes into craft-print that lists printers or reaches the
spooler or a driver: craft_print::printers and submit, and rgb's
printers, default_printer, page, print and settings_dialog. A panic
inside the lock does not block later callers. While a print job is
being handed to the spooler, File › Print waits for it before the
dialog opens.

Session::printer_source supplies the printers that file.printers,
file.print.printers and the Print dialog list, in place of the
spooler's. The tests that open Print or list printers set it, so they
no longer query the system's printers or load their drivers.
print_cmds::system_printer_listings counts the real listings, and the
dialog and print job tests assert that it stays 0. The app leaves
printer_source unset and lists the spooler's printers as before.

New tests: printer_listings_enter_the_spooler_one_thread_at_a_time
(eight threads list printers at once; it fails without the lock) and
a_panic_inside_the_spooler_does_not_block_later_callers.
2026-10-17 20:54:13 -07:00
..
…
…