pcscd crashes when disconnecting / reconnecting USB device

Bug #1296288 reported by Ralph Scharpf
68
This bug affects 13 people
Affects Status Importance Assigned to Milestone
libusb-1.0 (Ubuntu)
Confirmed
Undecided
Unassigned
pcsc-cyberjack (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

$ lsb_release -rd
Description: Ubuntu Trusty Tahr (development branch)
Release: 14.04

$ apt-cache policy pcscd
pcscd:
  Installed: 1.8.10-1ubuntu1
  Candidate: 1.8.10-1ubuntu1
  Version table:
 *** 1.8.10-1ubuntu1 0
        500 http://de.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages
        100 /var/lib/dpkg/status

The HW used is a Reiner SCT supported by the following package:

$ apt-cache policy libifd-cyberjack6
libifd-cyberjack6:
  Installed: 3.99.5final.sp03-2
  Candidate: 3.99.5final.sp03-2
  Version table:
 *** 3.99.5final.sp03-2 0
        500 http://de.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages
        100 /var/lib/dpkg/status

The error occures mostly when disconnecting or reconnecting the device. Please wait a few seconds after changing conection state. I am unsure if the deamon is stable over time when the connection state is unchanged. I found the service missing in various scenarios. After crashing I found the following entries in syslog:

Mar 23 14:13:51 einstein kernel: [ 560.029754] pcscd[2560]: segfault at 7f062128c248 ip 00007f062128c248 sp 00007f0620a5cee0 error 14 in libc-2.19.so[7f06216d3000+1bb000]
Mar 23 14:14:30 einstein kernel: [ 599.765633] pcscd[2572]: segfault at 7f7840e4f248 ip 00007f7840e4f248 sp 00007f784061fee0 error 14 in libc-2.19.so[7f7841296000+1bb000]

I attached the crash report from /var/crash/_usr_sbin_pcscd.0.crash.

Revision history for this message
Ludovic Rousseau (ludovic-rousseau-gmail) wrote :

I can't find the attached /var/crash/_usr_sbin_pcscd.0.crash

I guess the crash occurs in the libifd-cyberjack6 driver and the bug should be reassigned to this package.

Revision history for this message
Ralph Scharpf (rscharpf) wrote : Re: [Bug 1296288] Re: pcscd crashes when disconnecting / reconnecting USB device

Sorry for the latency. I was very busy during the week.

I unpacked the crash file with apport-unpack. Unfortunately there is no dbg
package available so all binaries are stripped. Perhaps you can have a look to
the attached crash file and give a hint if it is the libifd-cyberjack6 driver.

On Sunday 23 Mar 2014 14:54:31 you wrote:
> I can't find the attached /var/crash/_usr_sbin_pcscd.0.crash
>
> I guess the crash occurs in the libifd-cyberjack6 driver and the bug
> should be reassigned to this package.

Revision history for this message
Ralph Scharpf (rscharpf) wrote :
Download full text (4.5 KiB)

I am also convinced that the bug is not inside the pcscd. It could be inside libifd-cyberjack6 or libusb. Please help investigating it.

The exact HW I am using is this device:

http://www.reiner-sct.com/produkte/chipkartenleser/cyberjack_secoder.html?pEl=2

To reproduce the bug let the device unconnecting and start the pcscd deamon with options "-d -f". Connect the device, disconnect the device and reconnect.

I compiled the source packages in order to investigate the bug a little deeper on my own. When the device is connected the first time a bunch of threads are spawned where 2 will last for longer time. The 2 mentioned threads have the IDs 5+6.

(gdb) info thr
  Id Target Id Frame
  6 Thread 0x7ffff555d700 (LWP 19617) "pcscd" 0x00007ffff75aab9d in nanosleep () at ../sysdeps/unix/syscall-template.S:81
  5 Thread 0x7ffff5d5e700 (LWP 19616) "pcscd" 0x00007ffff72c2fbd in poll () at ../sysdeps/unix/syscall-template.S:81
  2 Thread 0x7ffff71d4700 (LWP 19581) "pcscd" 0x00007ffff72c7c33 in select () at ../sysdeps/unix/syscall-template.S:81
* 1 Thread 0x7ffff7fcf740 (LWP 19580) "pcscd" 0x00007ffff72c7c33 in select () at ../sysdeps/unix/syscall-template.S:81

Thead with ID 5 will cause the crash later on: Looking into the call stack show the following:

(gdb) thr 5
[Switching to thread 5 (Thread 0x7ffff5d5e700 (LWP 19616))]
#0 0x00007ffff72c2fbd in poll () at ../sysdeps/unix/syscall-template.S:81
81 ../sysdeps/unix/syscall-template.S: No such file or directory.
(gdb) bt
#0 0x00007ffff72c2fbd in poll () at ../sysdeps/unix/syscall-template.S:81
#1 0x00007ffff658d248 in poll (__timeout=-1, __nfds=2, __fds=0x7ffff5d5def0) at /usr/include/x86_64-linux-gnu/bits/poll2.h:46
#2 linux_udev_event_thread_main (arg=<optimized out>) at ../../libusb/os/linux_udev.c:175
#3 0x00007ffff75a3182 in start_thread (arg=0x7ffff5d5e700) at pthread_create.c:312
#4 0x00007ffff72d030d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111

When disconnecting the device the thread with ID5 is gone while the one with ID5 is still present but in a strange state.

info threads
  Id Target Id Frame
  5 Thread 0x7ffff5d5e700 (LWP 19616) "pcscd" 0x00007ffff72c2fbd in poll () at ../sysdeps/unix/syscall-template.S:81
  2 Thread 0x7ffff71d4700 (LWP 19581) "pcscd" 0x00007ffff72c7c33 in select () at ../sysdeps/unix/syscall-template.S:81
* 1 Thread 0x7ffff7fcf740 (LWP 19580) "pcscd" 0x00007ffff72c7c33 in select () at ../sysdeps/unix/syscall-template.S:81
(gdb) thr 5
[Switching to thread 5 (Thread 0x7ffff5d5e700 (LWP 19616))]
#0 0x00007ffff72c2fbd in poll () at ../sysdeps/unix/syscall-template.S:81
81 ../sysdeps/unix/syscall-template.S: No such file or directory.
(gdb) bt
#0 0x00007ffff72c2fbd in poll () at ../sysdeps/unix/syscall-template.S:81
#1 0x00007ffff658d248 in ?? ()
#2 0x00007ffff7590868 in __elf_set___libc_thread_subfreeres_element___rpc_thread_destroy__ ()
#3 0x00007ffff7590860 in __elf_set___libc_thread_subfreeres_element_res_thread_freeres__ () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x0000000100000006 in ?? ()
#5 0x0000000100000005 in ?? ()
#6 0x00007ffff5d5e700 in ?? ()
#7 0x00007ffff5d5e700 in ?? ()
#...

Read more...

affects: pcsc-lite (Ubuntu) → pcsc-cyberjack (Ubuntu)
Revision history for this message
Ludovic Rousseau (ludovic-rousseau-gmail) wrote :

You can try to build a more recent version of libusb. The latest version is 1.0.18 and Ubuntu 14.04 should have version 1.0.17.
http://sourceforge.net/projects/libusb/files/libusb-1.0/

Is your reader supported by the CCID driver libccid?
http://pcsclite.alioth.debian.org/ccid.html

I do not have this device in my list. You can try http://pcsclite.alioth.debian.org/ccid.html#CCID_compliant

Revision history for this message
Ralph Scharpf (rscharpf) wrote :

I tried to assign the bug to the package pcsc-cyberjack. Not that I do not like you feedback, Ludovic, but I also hope that the maintainer of pcsc-cyberjack will also be informed about the issue. Do you think the bug is assigned right now?

Yes, I have the version 1.0.17 of libusb-1.0 installed. It is interesting that the version 1.17 is missing at sourceforge. I tried now the 1.18 version of libusb and libusbx but neither of them do change anything. With libusbx I even recognized a crash of pcscd when disconnecting the reader. But I was not able to reproduce it.

The reader seems not be supported by libccid. When I run src/parse the following output is provided for the reader:

 Parsing USB bus/device: 0C4B:0400 (bus 1, device 17)
 idVendor: 0x0C4B iManufacturer: Reiner-SCT
 idProduct: 0x0400 iProduct: cyberJack Secoder
  NOT a CCID/ICCD device

Is this the information you need?

Revision history for this message
Boyan Sotirov (lz1dsb) wrote :

I believe I'm affected by this...
Yesterday I upgraded from 13.10 to 14.04 and I noticed that. To be honest, I've had the same issue with 13.10, though I didn't have the time to dig into it. What's described here, matches my problem. Here're some outputs from my system:
$lsb_release -rd
Description: Ubuntu 14.04 LTS
Release: 14.04
$ apt-cache policy pcscd
pcscd:
  Installed: 1.8.10-1ubuntu1
  Candidate: 1.8.10-1ubuntu1
  Version table:
 *** 1.8.10-1ubuntu1 0
        500 http://bg.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages
        100 /var/lib/dpkg/status

$ apt-cache policy libifd-cyberjack6
libifd-cyberjack6:
  Installed: (none)
  Candidate: 3.99.5final.sp03-2
  Version table:
     3.99.5final.sp03-2 0
        500 http://bg.archive.ubuntu.com/ubuntu/ trusty/universe amd64 Packages

This is the card reader I'm using:
$ lsusb
Bus 002 Device 008: ID 076b:6622 OmniKey AG CardMan 6121

I've been using it for years without any issues on 12.04...

Revision history for this message
Boyan Sotirov (lz1dsb) wrote :

I was not able to attach the crash file... the page doesn't let me...

Revision history for this message
Boyan Sotirov (lz1dsb) wrote :

When I start the pcscd with a -f and -d options I've got the following output:

00000000 pcscdaemon.c:266:main() pcscd set to foreground with debug send to stdout
00000240 configfile.l:339:DBGetReaderList() Parsing conf file: /usr/local/etc/reader.conf.d
00000031 pcscdaemon.c:571:main() pcsc-lite 1.8.11 daemon ready.
00000160 hotplug_libudev.c:123:HPReadBundleValues() Cannot open PC/SC drivers directory: /usr/local/lib/pcsc/drivers
00000014 hotplug_libudev.c:124:HPReadBundleValues() Disabling USB support for pcscd.
00000011 hotplug_libudev.c:700:HPRegisterForHotplugEvents() No bundle files in pcsc drivers directory: /usr/local/lib/pcsc/drivers
00000010 hotplug_libudev.c:701:HPRegisterForHotplugEvents() Disabling USB support for pcscd

But then after the pcscd is restarted (I use sudo service pcscd restart) - everything works fine.
Also when I stop the pcscd before plugging out the USB reader - no issues.
The crash always happens when I plug off the reader and the pcscd is still running. But... isn't it supposed to be like that?

Revision history for this message
Knut Jähnig (knut-jaehnig) wrote :

Hi,
I got the same issue. I use a ReinerSCT cyberJack standart:

$ lsusb
Bus 005 Device 002: ID 0c4b:0500 Reiner SCT Kartensysteme GmbH

The device seems also not supported by libccid.
if I use the "fxcyberjack" diagnosetic programm it tells me that everything is OK.

What driver do I need for hotpluging this cardreader.

the Crach Report say:

pcscd 1.8.10 (Ubuntu 14.04 LTS)
crached in SIGABRT in __libc_message()

thanks in advantage.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in pcsc-cyberjack (Ubuntu):
status: New → Confirmed
Revision history for this message
Ralph Scharpf (rscharpf) wrote :

For me the workaround is to connect the cyberjack reader, wait a few seconds, and then explicitly request the start of pcscd by running "sudo service pcscd start". This works fine as long as the reader keeps connected during the client execution. "service pcscd start" will run pcscd only if it is not running.

This is ugly but would make life easier.

Revision history for this message
jph (jphorst) wrote :

I can confirm the problem.
After upgrade 12.04 to 14.04 chipcard reader cyberjack RFID Komfort is not working anymore.
"fxcyberjack" diagnostic programm says that everything is OK.
pcscd crashes after login as well as otherwise. (Package versions as reported above)
Unplugging reader or restarting pcscd does not solve the problem.
On the shell the following problem is reported:
*** Error in `/usr/sbin/pcscd': free(): corrupted unsorted chunks: 0x000000000087e8e0 ***

Revision history for this message
Boyan Sotirov (lz1dsb) wrote :

Is there any update on this bug? I've just installed the kernel 3.13.0-29 and the issue is still there...

Revision history for this message
Ralph Scharpf (rscharpf) wrote :

No sorry. I also tried the latest version of the driver from http://www.reiner-sct.com/. I assume that this bug comes actually from the libusb. Since the reiner-sct driver is not so common I doubt that there would be a respond when the bug is assigned to libusb. If you have an idea for an more commen, alternate HW that is also addressed by a daemon via libusb we should be able to verify the issue and create a report for libusb.

I have libusb only in use for the smart card reader and for a scanner. The scanner is addressed by xsane and this locks/terminates when the scanner is disconnected as sane is not well aware on a disconect of a scanner.

Any suggestions?

Revision history for this message
Jochen Sommer (launchpa1) wrote :

For the Reiner SCT devices the problem can be solved by:

1. adding a group "cyberjack" with an arbitrary GID
   -> sudo groupadd cyberjack

2. adding the users allowed to use the chipcard terminal to this group
   -> sudo usermod -aG cyberjack <user>

Revision history for this message
Wolf Pichler (w-pichler) wrote :

I can confirm this problem.

I could fix it by replacing my /lib/x86_64-linux-gnu/libusb-1.0.so.0.1.0
with the version libusb-1.0-0_1.0.9~rc3-2ubuntu1 (probably a newer version would also work, I just could not
find one).

The version which did NOT work:

apt-cache policy libusb-1.0-0
libusb-1.0-0:
  Installed: 2:1.0.17-1ubuntu2
  Candidate: 2:1.0.17-1ubuntu2
  Version table:
 *** 2:1.0.17-1ubuntu2 0
        500 http://archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
        100 /var/lib/dpkg/status

OS: Ubuntu 14.04 64bit
3.13.0-43-generic #72-Ubuntu SMP Mon Dec 8 19:35:06 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

pcscd --version
pcsc-lite version 1.8.10.
Copyright (C) 1999-2002 by David Corcoran <email address hidden>.
Copyright (C) 2001-2011 by Ludovic Rousseau <email address hidden>.
Copyright (C) 2003-2004 by Damien Sauveron <email address hidden>.
Report bugs to <email address hidden>.
Enabled features: Linux x86_64-pc-linux-gnu serial usb libudev usbdropdir=/usr/lib/pcsc/drivers ipcdir=/var/run/pcscd configdir=/etc/reader.conf.d

Smartcard reader:
HID Omnikey 3121 (https://www.hidglobal.com/products/readers/omnikey/3121)

Driver:
https://www.hidglobal.com/drivers/21278 which is ifdokccid_linux_x86_64-v4.0.5.5.bundle.

lsusb
Bus 002 Device 052: ID 076b:3022 OmniKey AG

###

Segfaults in syslog:

Dec 20 20:46:17 liberty kernel: [ 8543.889726] usb 2-1.3: new full-speed USB device number 6 using ehci-pci
Dec 20 20:46:17 liberty kernel: [ 8543.988226] usb 2-1.3: New USB device found, idVendor=076b, idProduct=3022
Dec 20 20:46:17 liberty kernel: [ 8543.988238] usb 2-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
Dec 20 20:46:17 liberty kernel: [ 8543.988244] usb 2-1.3: Product: Smart Card Reader USB
Dec 20 20:46:17 liberty kernel: [ 8543.988249] usb 2-1.3: Manufacturer: OMNIKEY AG
Dec 20 20:46:17 liberty mtp-probe: checking bus 2, device 6: "/sys/devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3"
Dec 20 20:46:17 liberty mtp-probe: bus: 2, device: 6 was not an MTP device
Dec 20 20:46:17 liberty kernel: [ 8543.999039] pcscd[29697]: segfault at 7f94f533d248 ip 00007f94f533d248 sp 00007f94f816aee0 error 14 in libgcc_s.so.1[7f94f5751000+16000]

Dec 20 21:39:48 liberty kernel: [11755.020679] pcscd[30310]: segfault at 7febd0909248 ip 00007febd0909248 sp 00007febd3736ee0 error 14

Dec 21 13:23:00 liberty kernel: [13600.803213] pcscd[30707]: segfault at 7fdf6a8eb248 ip 00007fdf6a8eb248 sp 00007fdf6a8dbee0 error 14 in libdbus-1.so.3.7.6[7fdf6af38000+44000]

Revision history for this message
disto2 (disto2) wrote :

Hi, this bug affects me too since I'am using Ubuntu 14.04
I can confirm the solution posted by Wolf Pichler.
But my problem is that in Ubuntu 14.04 some Packages depends on libusb1.0-0 in Version 2:1.0.17-1ubuntu2.
So in my case I can't use the old version libusb-1.0-0_1.0.9~rc3-2ubuntu1.

After I installed the older version suggested by Wolf it worked without any problems. I was able to stop the deamon without getting an error. And it was also possible to unplug the card reader without any error message. Then I did an apt-get upgrade und reinstalled the newer version. From that moment the errors went back. So stopping the deamon or unplugging the device will bring the error.

It is possible as described erlier to manually start the deamon but in my household the other users aren't sudoers but have to work with the card reader. So this is not a solution.

My device is a REINERSCT Cyberjack RFID Standard.

In my case the error appears spodaric after the system has startet. Sometimes the error appears and sometimes not.

best regards

dirk

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in libusb-1.0 (Ubuntu):
status: New → Confirmed
Revision history for this message
Joachim Jacob (joachim-jacob) wrote :

I am using device 1a44:0001 VASCO Data Security International Digipass 905 SmartCard Reader
I am on Ubuntu 14.04.

Unplugging or plugging in this device causes pscsd to crash. Syslog output:
Jul 26 18:36:10 Studio-Hybrid-140g kernel: [ 1869.326342] pcscd[5518]: segfault at 7fd75e71f248 ip 00007fd75e71f248 sp 00007fd75e70fee0 error 14 in libgcc_s.so.1[7fd75e92d000+16000]

Not able to resolve the crash, and get my card reader reliably working. BUT I have a workaround, for who's fighting with this.

Kill pcscd. Plug the smart card reader in, and within one second (!) restart pcscd:
sudo service pcscd restart

The smartcard reader gets detected, and pcscd keeps on running. For what it's worth... Hope this helps.

Revision history for this message
Wolf Pichler (w-pichler) wrote :

It seems that after unplugging one of the devices which are causing problems the subsequent plugging of ANY USB device leads to a crash of pcscd.

I checked this with two Smartcard Readers (Gemalto PC Twin Reader and IDENTIV CLOUD 2700 F) which are both working perfectly fine, and one USB flash drive.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.