Bug 581136 - gscan2pdf randomly abborting multiple-pages scanning
Summary: gscan2pdf randomly abborting multiple-pages scanning
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: gscan2pdf
Version: 12
Hardware: x86_64
OS: Linux
low
medium
Target Milestone: ---
Assignee: Bernard Johnson
QA Contact: Fedora Extras Quality Assurance
URL: http://sourceforge.net/tracker/?func=...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-04-10 12:47 UTC by Boricua
Modified: 2010-08-20 01:37 UTC (History)
4 users (show)

Fixed In Version: gscan2pdf-0.9.31-1.fc13
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2010-08-19 01:12:01 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Graphic view of reported bug in action (321.49 KB, image/png)
2010-04-10 12:47 UTC, Boricua
no flags Details
Fixes race condition when gscan2pdf looks for outN.pnm file before it is provided by scanimage-perl. (781 bytes, patch)
2010-04-27 19:21 UTC, pscottdv
no flags Details | Diff
Non-blocking wait for image (943 bytes, patch)
2010-05-05 05:08 UTC, Jeffrey Ratcliffe
no flags Details | Diff

Description Boricua 2010-04-10 12:47:49 UTC
Created attachment 405712 [details]
Graphic view of reported bug in action

Description of problem: gscan2pdf aborts scans at random when scanning multiple pages

Version-Release number of selected component (if applicable): gscan2pdf 0.9.30

How reproducible: using a scanner with document feeder for multiple pages scanning.

Steps to Reproduce:
1.Place a batch of five or more pages in the scanner document feeder.
2.Start gscan2pdf and request multiple pages scanning.
3.Start scanning.
  
Actual results: It starts scanning normally. Then, after the first page and at random the program stops scanning, forcing user to start scanning again from the first aborted page.

Expected results: To keep scanning flawlessly up to the last page.

Additional info: I have two brother MFC scanners connected via my home/office network. Using either one shows the same behavior. This time, I started gscan2pdf from the console and placed a 3-pages legal-size document for scan. No problem. Then I tried a 15-pages legal size document. The bug appeared after successful scan of the fourth page. Here is the output from the console:

[Francisco@Hogar Desktop]$ gscan2pdf
Useless use of sort in void context at /usr/bin/gscan2pdf line 8749.
gscan2pdf 0.9.30
Startup LC_NUMERIC C
scanimage-perl: rounded value of br-x from 215.9 to 215.88
scanimage-perl: rounded value of br-y from 355.6 to 355.567
scanimage-perl: rounded value of br-x from 215.9 to 215.88
scanimage-perl: rounded value of br-y from 355.6 to 355.567
scanimage-perl: rounded value of br-x from 215.9 to 215.88
scanimage-perl: rounded value of br-y from 355.6 to 355.567
scanimage-perl: rounded value of br-x from 215.9 to 215.88
scanimage-perl: rounded value of br-y from 355.6 to 355.567
scanimage-perl: rounded value of br-x from 215.9 to 215.88
scanimage-perl: rounded value of br-y from 355.6 to 355.567
scanimage-perl: rounded value of br-x from 215.9 to 215.88
scanimage-perl: rounded value of br-y from 355.6 to 355.567
scanimage-perl: rounded value of br-x from 215.9 to 215.88
scanimage-perl: rounded value of br-y from 355.6 to 355.567
*** unhandled exception in callback:
***   can't open out5.pnm: No such file or directory at /usr/bin/gscan2pdf line 6654.
***  ignoring at /usr/bin/gscan2pdf line 12054.

I then started scanning again from the same scanner.  This time, it scanned up to the sixth page and stopped again, this time with this additional output:

scanimage-perl: rounded value of br-x from 215.9 to 215.88
scanimage-perl: rounded value of br-y from 355.6 to 355.567
*** unhandled exception in callback:
***   can't open out6.pnm: No such file or directory at /usr/bin/gscan2pdf line 6654.
***  ignoring at /usr/bin/gscan2pdf line 12054.

Finally, I tried with the other MFC machine with the same batch of pages and got the same result after just the third page, with this output:

[Francisco@Hogar Desktop]$ gscan2pdf
Useless use of sort in void context at /usr/bin/gscan2pdf line 8749.
gscan2pdf 0.9.30
Startup LC_NUMERIC C
scanimage-perl: rounded value of br-x from 215.9 to 215.88
scanimage-perl: rounded value of br-y from 355.6 to 355.567
*** unhandled exception in callback:
***   can't open out3.pnm: No such file or directory at /usr/bin/gscan2pdf line 6654.
***  ignoring at /usr/bin/gscan2pdf line 12054.

Finally, I'm attaching a screenshot of the bug as it happened the first time herein reported. Just let me know if anything else is needed and I'll find the time to do it,

Comment 1 pscottdv 2010-04-20 22:50:48 UTC
I can verify this bug with an HP 6110 all-in-one.  This really makes the program nearly useless for me.  I need to be able to scan unattended.

This output:

*** unhandled exception in callback:
***   can't open out6.pnm: No such file or directory at /usr/bin/gscan2pdf line 6654.

Seems to appear whenever the thing decides (incorrectly) that the scan job is complete.

Comment 2 pscottdv 2010-04-21 23:02:10 UTC
I have a little more information.  Changed /usr/bin/gscan2pdf to run in debug mode and was able to get the temporary files directory.  Here is the error message:

*** unhandled exception in callback:
***   can't open out3.pnm: No such file or directory at /usr/bin/gscan2pdf line 6654.
***  ignoring at /usr/bin/gscan2pdf line 12058.

but here is a listing of the temporary directory:

$ ls -l
total 784
-rw-r--r-- 1 myusername myusername 263713 2010-04-21 17:11 EHnFbcM9ou.pnm
-rw-r--r-- 1 myusername myusername 263713 2010-04-21 17:12 out3.pnm
-rw-r--r-- 1 myusername myusername     43 2010-04-21 17:10 session
-rw-r--r-- 1 myusername myusername 263713 2010-04-21 17:11 VxZwQQuL6d.pnm

So the file does exist.

The offending line in /usr/bin/gscan2pdf is:

open my $fh, '<', $ofilename or die "can't open $ofilename: $!";

So what is going on?  Has the scanning process perhaps not release the file yet?

I suspected a race condition so I added the following code before line 6654 where the temporary scan file is opened (forgive me if this is a mess -- I have never coded in Perl before)

 my $trytime = (time + 2);
 my $foundfile = FALSE;
 while ( time < $trytime )
 {
  print "Waiting for $ofilename\n" if ($debug);
  if ( -e $ofilename )
  {
   $foundfile = TRUE;
   last;
  }
 }
 if ( ! $foundfile) {
  die "can't wait for $ofilename any longer";
 }

The output shows section such as:


Header suggests 263713
Expecting 263713, found 263713
Importing out15.pnm, format Portable anymap
Added /tmp/0GZ2YuDfd3/iitXHEZycs.pnm at page 15 with resolution 150
Scanned page 16. (scanner status = 5)
Waiting for out16.pnm
Scanning page 17
Format is P4
Header is 33
Header suggests 263713
Expecting 263713, found 263713
Importing out16.pnm, format Portable anymap
Added /tmp/0GZ2YuDfd3/tSbXx7Vwpv.pnm at page 16 with resolution 150
Scanned page 17. (scanner status = 5)
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Waiting for out17.pnm
Scanning page 18
Format is P4
Header is 33
Header suggests 263713
Expecting 263713, found 263713
Importing out17.pnm, format Portable anymap
Added /tmp/0GZ2YuDfd

I therefore conclude that I was correct--there is a race condition.  I will leave it to better Perl programmers to fix the code properly, but this works for now if anyone else is having this problem.

Comment 3 pscottdv 2010-04-27 19:21:30 UTC
Created attachment 409558 [details]
Fixes race condition when gscan2pdf looks for outN.pnm file before it is provided by scanimage-perl.

I have been using the patch and have had no problems with it.  Debug output shows that it is frequently "needed" (i.e. gscan2pdf frequently attempts to open outN.pnm before scanimage-perl has created it).

Comment 4 Bernard Johnson 2010-05-03 17:52:29 UTC
pscottdv, thanks for getting the report upstream.  I'd like to wait a bit and get a comment from the author before proceeding on this.

Comment 5 Jeffrey Ratcliffe 2010-05-04 05:31:35 UTC
Does this happen with the other frontends - particularly the scanimage frontend?

Comment 6 Jeffrey Ratcliffe 2010-05-05 05:08:12 UTC
Created attachment 411472 [details]
Non-blocking wait for image

Please test this alternative patch, which doesn't wait in a busy loop and therefore doesn't block the GUI.

Comment 7 Fedora Update System 2010-05-09 16:29:39 UTC
gscan2pdf-0.9.30-6.fc13 has been submitted as an update for Fedora 13.
http://admin.fedoraproject.org/updates/gscan2pdf-0.9.30-6.fc13

Comment 8 Fedora Update System 2010-05-09 16:30:48 UTC
gscan2pdf-0.9.30-6.fc12 has been submitted as an update for Fedora 12.
http://admin.fedoraproject.org/updates/gscan2pdf-0.9.30-6.fc12

Comment 9 Bernard Johnson 2010-05-09 16:34:48 UTC
Please test these candidate builds.  They have Jeffrey's patch included.

Comment 10 Fedora Update System 2010-05-10 17:04:30 UTC
gscan2pdf-0.9.30-6.fc12 has been pushed to the Fedora 12 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update gscan2pdf'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/gscan2pdf-0.9.30-6.fc12

Comment 11 Fedora Update System 2010-05-10 21:50:07 UTC
gscan2pdf-0.9.30-6.fc13 has been pushed to the Fedora 13 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update gscan2pdf'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/gscan2pdf-0.9.30-6.fc13

Comment 12 Boricua 2010-05-11 13:32:53 UTC
Problem seems to be solved, but please refer to my comment for bug 586350.

Comment 13 Fedora Update System 2010-08-08 15:52:45 UTC
gscan2pdf-0.9.31-1.fc14 has been submitted as an update for Fedora 14.
http://admin.fedoraproject.org/updates/gscan2pdf-0.9.31-1.fc14

Comment 14 Fedora Update System 2010-08-08 15:53:47 UTC
gscan2pdf-0.9.31-1.fc13 has been submitted as an update for Fedora 13.
http://admin.fedoraproject.org/updates/gscan2pdf-0.9.31-1.fc13

Comment 15 Fedora Update System 2010-08-10 01:28:46 UTC
gscan2pdf-0.9.31-1.fc14 has been pushed to the Fedora 14 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update gscan2pdf'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/gscan2pdf-0.9.31-1.fc14

Comment 16 Fedora Update System 2010-08-10 21:43:02 UTC
gscan2pdf-0.9.31-1.fc13 has been pushed to the Fedora 13 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update gscan2pdf'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/gscan2pdf-0.9.31-1.fc13

Comment 17 Fedora Update System 2010-08-19 01:11:48 UTC
gscan2pdf-0.9.31-1.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 18 Fedora Update System 2010-08-20 01:37:13 UTC
gscan2pdf-0.9.31-1.fc13 has been pushed to the Fedora 13 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.