Bug 92478 - CRASH when open "scan > scanner source" on windows 10 x64.
Summary: CRASH when open "scan > scanner source" on windows 10 x64.
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
5.0.0.2 rc
Hardware: x86-64 (AMD64) Windows (All)
: high major
Assignee: Not Assigned
QA Contact:
URL:
Whiteboard: target:5.3.0 target:5.2.0.1 target:5.1.4
Keywords:
: 91615 94581 99747 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-07-01 12:35 UTC by sawakaze
Modified: 2017-02-06 06:55 UTC (History)
15 users (show)

See Also:
Crash report or crash signature: ["ImpTwain::ImplHandleMsg(void *)"]


Attachments
Backtrace (LO 5.0.1.1) (8.33 KB, text/plain)
2015-08-11 12:39 UTC, Helmut Leininger
Details
backtrace, Linux, dbgutil 2015-08-08 (15.25 KB, text/plain)
2015-08-13 22:04 UTC, Terrence Enger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description sawakaze 2015-07-01 12:35:50 UTC
Hi,

After select "insert > Media > Scan > Select Source..." on writer, crash application.

it is caused on windows 10 x64 and libreoffice 5.0 x64 binary.
It is "not" caused on linux debian x64 and libreoffice 5.0 x64 binary(RC1).

OS : Windows 10
Version: 5.0.0.2.0+ (x64)
Build ID: 18d6d789cae7cd684156dbd41d473892bc17392c
Locale: ja-JP (ja_JP)

regards.
Sawakaze.
Comment 1 raal 2015-07-01 20:30:03 UTC
I can confirm with Version: 5.1.0.0.alpha1+ (x64)
Build ID: 492ff21d6543d800b0cd424eafbcd409bc19f695
TinderBox: Win-x86_64@62-TDF, Branch:MASTER, Time: 2015-06-23_22:13:16
win10
Comment 2 Helmut Leininger 2015-08-10 08:59:30 UTC
Same problem with LO
Version: 5.0.0.5 (x64)
Build-ID: 1b1a90865e348b492231e1c451437d7a15bb262b
Gebietsschema: de-AT (de_AT)

Impossible to scan any document within LO (not only Writer). LO crashes and proceeds to the document recovery screen.
Comment 3 jmisenta.com 2015-08-10 20:43:16 UTC
Same Problem with
Version: 5.0.0.5 (x64)
Build-ID: 1b1a90865e348b492231e1c451437d7a15bb262b
Gebietsschema: de-CH (de_DE)

WIN 10 Pro 
Version 10.0.10240 Build 10240

Scanners:
Epson Perfection V200 Photo
Canon MG 3550

LO crashes instantly when clicking insert/media/scan/choose source or scan.
Comment 4 Christian Lohmaier 2015-08-11 11:57:53 UTC
would be interesting to know whether this also occurs with the 32bit version of  LibreOffice.

But in any case, if possible try to create a backtrace - as LO crashes, it should be easy to obtain:

https://wiki.documentfoundation.org/How_to_get_a_backtrace_with_WinDbg
Comment 5 Helmut Leininger 2015-08-11 12:39:41 UTC
Created attachment 117823 [details]
Backtrace (LO 5.0.1.1)

The test was done with 
Version: 5.0.1.1 (x64)
Build-ID: 13f702ca819ea5b9f8605782c852d5bb513b3891
Gebietsschema: de-AT (de_AT)
Comment 6 Helmut Leininger 2015-08-11 13:01:06 UTC
The problem does not occur in the 32-bit version of LO.

Version: 5.0.1.1
Build-ID: 13f702ca819ea5b9f8605782c852d5bb513b3891
Gebietsschema: de-AT (de_AT)

Scanning is ok.
Comment 7 Terrence Enger 2015-08-13 22:04:24 UTC
Created attachment 117908 [details]
backtrace, Linux, dbgutil 2015-08-08

I had given up on this one, because I was unable to make it happen
again.  But the report is here, so let me add my c$0.02.

The attached backtrace comes from my very first attempt to use the
scanner in any program.  The default scanner was blank upon entry to
the dialog, and the list was empty each time thereafter.  However,
"Simple Scan 3.4.2" running on Debian-wheezy did detect the scanner
and successfully scanned a handful of pages.  the scanner in question
is HP OfficeJet 5610.

I am setting O/S All and changing summary from "CRASH when open "scan
> scanner source" on windows to "segfault when open "scan > scanner
source".
Comment 8 Michael Meeks 2015-08-18 19:35:42 UTC
Odd indeed:

Thread 1 (Thread 0x7f7e11697700 (LWP 5043)):
#0  0x00007f7e089dafd8 in ?? ()
#1  0x00007f7e4d596878 in __elf_set___libc_thread_subfreeres_element___rpc_thread_destroy__ ()
#2  0x00007f7e4d3411f2 in __libc_thread_freeres () at thread-freeres.c:29
#3  0x00007f7e4cfe20a4 in start_thread (arg=0x7f7e11697700) at pthread_create.c:309
#4  0x00007f7e4d2dcccd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

suggests that some memory corruption has occurred that breaks the thread teardown - it would be great to have full symbols and run this under valgrind if possible & get a log (?) =)
Comment 9 ribotb 2015-09-07 06:59:53 UTC
Bug confirmed on users-fr list : http://nabble.documentfoundation.org/bug-scanner-tp4159232.html

Bernard
Comment 10 raal 2015-10-08 10:29:27 UTC
*** Bug 94581 has been marked as a duplicate of this bug. ***
Comment 11 Yousuf Philips (jay) 2016-03-02 22:34:32 UTC
*** Bug 91615 has been marked as a duplicate of this bug. ***
Comment 12 dabujo 2016-04-15 07:03:38 UTC
Since the bug is still present in 5.1.2.2 i want to confirm it once more.
I've had this problem on all installations of 5.x x64 on Win 10 x64.

This has been reproducible on all installations I've tried for months now which have been several in my family.

This means no one can use the built in scan function on Win 10 x64 with Libreoffice 5 x64 installed which should be one of the most common configurations!

Switching to Libreoffice 5 x32 fixes it.
Comment 13 lal 2016-04-16 07:48:55 UTC
I confirm the same here. Has not worked for a long time. A big reason for not using the x64 version
Comment 14 Julien Nabet 2016-05-04 23:03:43 UTC
About the fact it works on Win32 and not on Win64, I noticed this:

     63 #if defined(_WIN32)
     64 #define TWAIN_LIBNAME           "TWAIN_32.DLL"
     65 #define TWAIN_FUNCNAME          "DSM_Entry"
     66 #endif
(see http://opengrok.libreoffice.org/xref/core/extensions/source/scanner/scanwin.cxx#63)

so for WIN64, TWAIN_LIBNAME is not defined at all or at minimum empty.
TWAIN_LIBNAME is used in ImpTwain::ImplOpenSourceManager
    252         if( pMod->load( OUString( TWAIN_LIBNAME  ) ) )
    253         {
    254             nCurState = 2;
    255 
    256             pDSM = (DSMENTRYPROC) pMod->getSymbol(OUString(TWAIN_FUNCNAME));
(see http://opengrok.libreoffice.org/xref/core/extensions/source/scanner/scanwin.cxx#246)

but since we'll load nothing, pDSM will stay unchanged from the way it has been created by constructor:
    152 ImpTwain::ImpTwain( ScannerManager& rMgr, const Link<unsigned long,void>& rNotifyLink ) :
    153             mxMgr( uno::Reference< scanner::XScannerManager >( static_cast< OWeakObject* >( &rMgr ), uno::UNO_QUERY) ),
    154             mrMgr( rMgr ),
    155             aNotifyLink( rNotifyLink ),
    156             pDSM( NULL ),

ie NULL.

Finally, we arrive in ImpTwain::ImplHandleMsg with this instruction:
nRet = PFUNC( &aAppIdent, &aSrcIdent, DG_CONTROL, DAT_EVENT, MSG_PROCESSEVENT, &aEvt );

and since PFUNC correspond to (*pDSM) => Crash!
(see http://opengrok.libreoffice.org/xref/core/extensions/source/scanner/scanwin.cxx#PFUNC)

So should we remove "if defined(_WIN32)" and consider the 2 defines are ok?

Or is there some TWAIN_64.DLL?

Michael: any idea who may have some experience with scanner/Twain?
Comment 15 Helmut Leininger 2016-05-05 06:33:39 UTC
Just a remark, I don't know if it helps.

I tried to scan with Corel Paintshop Pro X7 in Windows 10 64-bit (and Epson V600 scanner) with the following experience:

Paintshop 64-bit version does not find a scanner.
Paintshop 32-bit version woeks ok.

For me, if the software/drivers delivered with the scanner are not 64-bit, you will not be able to use it in a "standard way" with 64-bit software. The difference to LO is that Paintshop 64-bit does not offer to select a scanner, whereas LO does and crashes afterwards.
Comment 16 Michael Meeks 2016-05-05 09:49:19 UTC
Hi Julien - your diagnosis is almost certainly rather near the mark =) I imagine it will not be easy (or even possible) to use the 32bit DLL in 64bit code since it will want to allocate and be passed 32bit pointers. But I'm no expert on this.

I imagine that simply disabling twain unless there is a 64bit DLL around that we can use instead would be the best approach =) hopefully easy enough to fix ?
Comment 17 Julien Nabet 2016-05-05 11:54:38 UTC
Thank you Michael for your feedback! I haven't searched yet but indeed disabling may be not too difficult.

Anyway, I kept on the investigation and found interesting pieces.
First "twain_32.dll" in Windows is the Twain DSM (Data Source Manager) 32 bits (obviously) version 1.9.
See https://www.data-tech.com/help/imnettwain/TWAIN%201.9%20and%202.1%20Support%20.html
(I know, I would have preferred a more official source like Twain or Microsoft website :-( )

However it exists not only an even more recent 2.3 DSM version, but the package contains 32 and 64 version! (see https://sourceforge.net/projects/twain-dsm/files/?source=navbar)

Unzipping twaindsm-2.3.0.win.bin.zip gives:
./twain32
./twain32/TWAINDSM32.msm
./twain32/TWAINDSM.dll
./ChangeLog.txt
./TODO.txt
./twain64
./twain64/TWAINDSM64.msm
./twain64/TWAINDSM.dll
./README.txt
./license.txt

So since I suppose it won't be easy to ask Microsoft to include update of Twain + embed its 64 bits version, perhaps we could embed it on LO? (at least 64 bits version)
Here are the sizes:
150736 déc.  13  2013 ./twain32/TWAINDSM.dll
168144 déc.  13  2013 ./twain64/TWAINDSM.dll

Another potential gain is a better match with twain.h present in LO sources.

If so, it means some packaging work (which is beyond my capabilities).

So for now, I'm waiting end of my local build and will take a look for disabling the entry for workaround. Since I only use Linux to build LO, I won't be able to test the result.
Comment 18 Julien Nabet 2016-05-05 16:46:01 UTC
I took a look about disabling, noticed this http://opengrok.libreoffice.org/search?q=SID_TWAIN_SELECT&project=core&defs=&refs=&path=&hist=, but don't know how to do then.

Certainly someone will know how to do.
Comment 19 Terrence Enger 2016-05-09 16:43:38 UTC
*** Bug 99747 has been marked as a duplicate of this bug. ***
Comment 20 Stan 2016-05-10 14:23:08 UTC
This makes the scanner unusable in this program.
Comment 21 kaffein 2016-06-03 00:13:10 UTC
OS : Windows 10 Professional 
Version: 5.1.3.2
Build ID: 644e4637d1d8544fd9f56425bd6cec110e49301b
CPU Threads: 4; OS Version: Windows 6.2; UI Render: GL; 
Locale: en-US (en_US)


I have the same issue as of 5.1.3.2 in Windows 10 Professional 64bit on 2 machines.  I had to go back to an old version of oOO to complete the task. :<

Canon Lide 120 scanner and a Brother scanner.  
Works fine in any other applications.

It's not a 100% repeatable bug, as SOMETIMES it will work.

Steps:
Insert > Media > Scan > Select Source (Correct source is selected)
Insert > Media > Scan > Request > Preview
Insert > Media > Scan > Request > Scan
Scan hangs on transferring data and says "wait..." when I cancel.
I must kill the process in task manager to "Cancel."
Comment 22 kaffein 2016-06-03 06:14:39 UTC
(In reply to kaffein from comment #21)
> OS : Windows 10 Professional 
> Version: 5.1.3.2
> Build ID: 644e4637d1d8544fd9f56425bd6cec110e49301b
> CPU Threads: 4; OS Version: Windows 6.2; UI Render: GL; 
> Locale: en-US (en_US)
> 
> 
> I have the same issue as of 5.1.3.2 in Windows 10 Professional 64bit on 2
> machines.  I had to go back to an old version of oOO to complete the task. :<
> 
> Canon Lide 120 scanner and a Brother scanner.  
> Works fine in any other applications.
> 
> It's not a 100% repeatable bug, as SOMETIMES it will work.
> 
> Steps:
> Insert > Media > Scan > Select Source (Correct source is selected)
> Insert > Media > Scan > Request > Preview
> Insert > Media > Scan > Request > Scan
> Scan hangs on transferring data and says "wait..." when I cancel.
> I must kill the process in task manager to "Cancel."

Forgot to mention: I'm using the 32bit application as well.
Comment 24 Commit Notification 2016-06-12 13:50:10 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=7c983445656e1f1942cf2d7398a77342004ed168

Resolves: tdf#92478 avoid crash on using scanner on windows x64

It will be available in 5.3.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 25 Commit Notification 2016-06-14 11:41:31 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-5-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=05258d0277e822908c255da8e3d14da0e0656fc2&h=libreoffice-5-1

Resolves: tdf#92478 avoid crash on using scanner on windows x64

It will be available in 5.1.5.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 26 Commit Notification 2016-06-14 15:06:17 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-5-2":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=63869fbbf1e092cc1f3deab21b7c0d8cab40abca&h=libreoffice-5-2

Resolves: tdf#92478 avoid crash on using scanner on windows x64

It will be available in 5.2.0.1.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 27 Commit Notification 2016-06-14 19:53:21 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-5-1-4":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=03d2fd41266083f4aa200bce3f27c5b5f8cbba42&h=libreoffice-5-1-4

Resolves: tdf#92478 avoid crash on using scanner on windows x64

It will be available in 5.1.4.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 28 petitlou60 2016-06-19 09:14:47 UTC
Yes now do not crash when attempt to scan

but NOTHING DONE  on WINx64

On WINx86 select TWAIN source , scan start but nothing is retieved
          but when select WIA source , all is right


suggestion concentrate debuging on WIA source because on some scanners
TWAIN drivers are only 32 bits  but Microsoft provide WIA pilots in both
32 bits and 64 bits

Best regards
Comment 29 Caolán McNamara 2016-06-21 09:23:31 UTC
TWAIN-2.3-Spec.pdf says...
  
The TWAIN DSM is a shared library named TWAINDSM.DLL.  There is a 32-bit and a 64-bit version of this file.

All TWAIN 2.x Sources must be prepared to work with either TWAINDSM.DLL or TWAIN_32.DLL, which may still be used by older Applications.

Which suggests that https://gerrit.libreoffice.org/#/c/26541/ might make scanning work on win64
Comment 30 Commit Notification 2016-07-07 11:56:36 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=3cecadbddd137770552ceaad018336e195233e4a

Related: tdf#92478 speculative win64 scanning fix

It will be available in 5.3.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 31 Caolán McNamara 2016-08-19 14:50:27 UTC
I reckon the crash should be fixed. Doesn't mean scanning actually works on 64bit windows, just that it doesn't crash. Installing the 64bit twain dll on windows might now make it work, but someone will have to experiment to see if that is actually the case
Comment 32 petitlou60 2017-02-03 11:08:52 UTC
Hello,

I have seen a microsoft message which says that TWAIN drivers are now deprecated
and are replaced by WIA drivers which are 32 and 64 bit

To Day 32 bits LO can scan with WIA drivers (on some scanners ie brother TWAIN scan seems good but no data is transferred)

So i suggest the following for both 32 and 64 bits LO:

1) when select scanner ignore TWAIN, propose only WIA  so lack of 64 bit twain dll doest not arise

2) scan in WIA mode where 64 bits drivers is present


I think that this bug which for many users lock use of 64 bits LO is a very bad advertising for LO

Can you Work to solve this by using exclusiveley WIA mode, so we can use 64 bit LO on 64 bits Windows


Best regards
Comment 33 Julien Nabet 2017-02-03 11:22:48 UTC
(In reply to petitlou60 from comment #32)
...
> Can you Work to solve this by using exclusiveley WIA mode, so we can use 64
> bit LO on 64 bits Windows
> 

Could you please create a new bugtracker for enhancement?
Indeed, this one is FIXED so it's not very useful to comment it for some enhancement.
Also, WIA is a Microsoft technology which isn't implemented on Linux or MacOs I think. So it would be specific Windows.