[Pcsclite-muscle] Crash in SCardStatus

Jonathan Verner jonathan.verner at nexusgroup.com
Tue Nov 24 07:27:30 EST 2020


I work for Nexus where we develop smartcard middleware and we use  libpcsc-lite. Recently, we have started seeing crashes on Linux (Ubuntu 18.04, which has libpcsc-lite version 1.8.23) when calling SCardStatus​ from our code. I suspect that the problem has to do with multiple threads calling into libpcsc-lite. 

In particular, the crash seems to happen when SCardStatus​ is called and, before it finishes, SCardDisconnect​ is called:

   The crash happens in SCardStatus​ on line 1440​ of winscard_clnt.c​ due to r (=pChannelMap->readerName)
   no longer pointing to valid memory. My hypothesis is that, while calling getReaderStates​ on line 1434​, a call to
   SCardDisconnect​ arrives and frees the memory pointed to by pChannelMap​->readerName.

On the other hand, I am quite new to pcsc and perhaps my analysis is incorrect (I am attaching the logs I get from pcscd and pcsc-spy if someone would be willing to look at them).  Anyway, I wanted to know, if there is some documentation on how to safely call libpcsc-lite functions from multiple threads.

Thanks for any pointers!



Jonathan Verner, PhD.
software engineer

Nexus Group
Evropska 33/A
160 00 Praha 6
Czech Republic
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pcscd-log202011-24-11-48.gz
Type: application/gzip
Size: 17812 bytes
Desc: pcscd-log202011-24-11-48.gz
URL: <http://lists.infradead.org/pipermail/pcsclite-muscle/attachments/20201124/4d0f427d/attachment-0002.gz>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pcsc-client-log202011-24-11-49.gz
Type: application/gzip
Size: 4485 bytes
Desc: pcsc-client-log202011-24-11-49.gz
URL: <http://lists.infradead.org/pipermail/pcsclite-muscle/attachments/20201124/4d0f427d/attachment-0003.gz>

More information about the pcsclite-muscle mailing list