OpenPrinting / libcupsfilters

Apache License 2.0
3 stars 21 forks source link

Critical Issue: Deadlock in Filter Chain When One Filter Fails #32

Open sahayap opened 1 year ago

sahayap commented 1 year ago

Dear Support Team,

I hope you all doing well. We are currently in the final stages of developing AirPrint support for our label printers and have now entered the crucial testing phase. Regrettably, we have encountered an unexpected issue during testing that revolves around the "print processing" phase, necessitating a printer reboot to resume normal operation.

We are using libcupsfilters-2.0b4,libppd-2.0b4, libpappal-retrofit-1.0b2, libpappl-1.3.2 , cups-2.4.5, poppler-21.05.0, qpdf-11.1.1

Outlined below is an overview of our testing procedure:

  1. We establish a connection between our label printer and a Mac OS system via USB.
  2. A series of PDF test files, each sized 4x6 inches, are enqueued for printing.
  3. We initiate the printing of 10 jobs simultaneously and await their completion.
  4. Following the successful printing of the initial batch, we proceed to queue another set of 10 PDFs for printing.
  5. At unspecified intervals, the "print processing" problem arises. The printer enters a waiting state, and no further print jobs are executed until a full printer reboot is performed.

Upon a thorough analysis of the printer's terminal output, we observed the presence of multiple instances of our printer application running concurrently. This observation raises the possibility that the "print processing" issue could be correlated with this phenomenon.

threads

Upon delving deeper into the matter, our investigation has led us to suspect a connection with the libcupsfilters2 component. Specifically, our focus has centered on the 'cfFilterChain' function located within the 'filter.c' file. It has come to our attention that this particular function is responsible for spawning four child processes, each representing a filter chain. These child processes are subsequently monitored using the 'wait' system call to ascertain their statuses.

The crux of the challenge appears when multiple print jobs are dispatched. Under certain conditions, a single filter process may encounter a failure. Unfortunately, this can result in the inadequate return of status for the affected child process. As a consequence, a deadlock scenario is induced, leading to the indefinite suspension of the remaining child processes.

In light of these findings, we kindly request your guidance on the best way to proceed in addressing this issue. Your insights and expertise would be immensely valuable as we strive to resolve this matter and ensure the successful implementation of AirPrint support for our label printers.

Thank you for your assistance and prompt attention to this matter.

Best Regards,

Sahaya Darcius P

tillkamppeter commented 11 months ago

To be able to fix this I would need a reproducer. Could you find a way to reproduce the bug? If needed perhaps even with a slight modification o one filter function, to provoke the bug. Thanks.