Difference from Windows' implementation with regard to PC/SC shared mode

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Difference from Windows' implementation with regard to PC/SC shared mode

Maksim Ivanov
Hello,

It seems that there's a difference between the PC/SC-Lite behavior and
the behavior of the Windows' implementation in the following scenario:

1. One thread obtains an hCard with SCARD_SHARE_SHARED.

2. This thread calls then SCardBeginTransaction with this hCard.

3. Another thread in the same application tries to obtain a new hCard
to the same card with SCARD_SHARE_SHARED.

Under Windows step #3 finishes successfully.
PC/SC-Lite, however, seems to block all new connections to the card
(even in the shared mode) until the previously started transaction
finishes.

Not sure whether this can be considered as a bug. It seems that there
are no guarantees about this use case in the PC/SC specification.

But even if this is not considered as a bug by the maintainers, it
would be good to cover this detail in the corresponding "Known
differences" list:
http://pcsclite.alioth.debian.org/api/group__API.html#differences


Regards,
Maksim

_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle
Reply | Threaded
Open this post in threaded view
|

Re: Difference from Windows' implementation with regard to PC/SC shared mode

Ludovic Rousseau
2016-10-17 19:26 GMT+02:00 Maksim Ivanov <[hidden email]>:
Hello,

Hello Maksim,
 

It seems that there's a difference between the PC/SC-Lite behavior and
the behavior of the Windows' implementation in the following scenario:

1. One thread obtains an hCard with SCARD_SHARE_SHARED.

2. This thread calls then SCardBeginTransaction with this hCard.

3. Another thread in the same application tries to obtain a new hCard
to the same card with SCARD_SHARE_SHARED.

Under Windows step #3 finishes successfully.
PC/SC-Lite, however, seems to block all new connections to the card
(even in the shared mode) until the previously started transaction
finishes.

Not sure whether this can be considered as a bug. It seems that there
are no guarantees about this use case in the PC/SC specification.

I could change pcsc-lite code to be more like Windows but:
- nobody complained about this
- it could has bad side effects if not done right
- it would take time to code and test
 

But even if this is not considered as a bug by the maintainers, it
would be good to cover this detail in the corresponding "Known
differences" list:
http://pcsclite.alioth.debian.org/api/group__API.html#differences


Good suggestion.
Thanks

--
 Dr. Ludovic Rousseau

_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle
Reply | Threaded
Open this post in threaded view
|

Re: Difference from Windows' implementation with regard to PC/SC shared mode

Michael Traut
Hi,

i can not unconditionally confirm this behavior under windows. At least when using different contexts, the second connect is blocked, even when it is shared. I have no example when the same context is used, this may differ.

Afaik reusing the same context in different threads is considered bad practice (http://muscle.musclecard.narkive.com/ZAn5vTFD/multiple-threads-and-scardgetstatuschange)?

Regards, Michael

On Wed, Oct 26, 2016 at 12:12 PM, Ludovic Rousseau <[hidden email]> wrote:
2016-10-17 19:26 GMT+02:00 Maksim Ivanov <[hidden email]>:
Hello,

Hello Maksim,
 

It seems that there's a difference between the PC/SC-Lite behavior and
the behavior of the Windows' implementation in the following scenario:

1. One thread obtains an hCard with SCARD_SHARE_SHARED.

2. This thread calls then SCardBeginTransaction with this hCard.

3. Another thread in the same application tries to obtain a new hCard
to the same card with SCARD_SHARE_SHARED.

Under Windows step #3 finishes successfully.
PC/SC-Lite, however, seems to block all new connections to the card
(even in the shared mode) until the previously started transaction
finishes.

Not sure whether this can be considered as a bug. It seems that there
are no guarantees about this use case in the PC/SC specification.

I could change pcsc-lite code to be more like Windows but:
- nobody complained about this
- it could has bad side effects if not done right
- it would take time to code and test
 

But even if this is not considered as a bug by the maintainers, it
would be good to cover this detail in the corresponding "Known
differences" list:
http://pcsclite.alioth.debian.org/api/group__API.html#differences


Good suggestion.
Thanks

--
 Dr. Ludovic Rousseau

_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle


_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle
Reply | Threaded
Open this post in threaded view
|

Re: Difference from Windows' implementation with regard to PC/SC shared mode

Ludovic Rousseau


2016-10-26 12:32 GMT+02:00 Michael Traut <[hidden email]>:
Hi,

i can not unconditionally confirm this behavior under windows. At least when using different contexts, the second connect is blocked, even when it is shared. I have no example when the same context is used, this may differ.

Interesting.
I must admit I have not tested the windows behavior on this. Maybe I should have test it myself :-(


Afaik reusing the same context in different threads is considered bad practice (http://muscle.musclecard.narkive.com/ZAn5vTFD/multiple-threads-and-scardgetstatuschange)?

Exact. Using the same hContext in different threads may lead to dead locks.

Maskim, can you try again on Windows but using 2 different hContext (SCardEstablishContext) in the 2 threads?

Thanks


--
 Dr. Ludovic Rousseau

_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle
Reply | Threaded
Open this post in threaded view
|

Re: Difference from Windows' implementation with regard to PC/SC shared mode

Maksim Ivanov
Hello,


On Wed, Oct 26, 2016 at 6:29 PM, Ludovic Rousseau
<[hidden email]> wrote:
> Maskim, can you try again on Windows but using 2 different hContext
> (SCardEstablishContext) in the 2 threads?

Sorry, I don't have a Windows device at hand. I'll try to find one and
see whether I can reproduce the issue.

I based my message on a report from one of our partners.

Though sorry for not mentioning explicitly that I didn't have a
reproducible test case.


2016-10-26 12:32 GMT+02:00 Michael Traut <[hidden email]>:
> Afaik reusing the same context in different threads is considered bad practice
> (http://muscle.musclecard.narkive.com/ZAn5vTFD/multiple-threads-and-scardgetstatuschange)?

That's true. Though in the case described by me two different handles were used.


Regards,
Maksim


On Wed, Oct 26, 2016 at 6:29 PM, Ludovic Rousseau
<[hidden email]> wrote:

>
>
>
> 2016-10-26 12:32 GMT+02:00 Michael Traut <[hidden email]>:
>>
>> Hi,
>>
>> i can not unconditionally confirm this behavior under windows. At least when using different contexts, the second connect is blocked, even when it is shared. I have no example when the same context is used, this may differ.
>
>
> Interesting.
> I must admit I have not tested the windows behavior on this. Maybe I should have test it myself :-(
>
>>
>> Afaik reusing the same context in different threads is considered bad practice (http://muscle.musclecard.narkive.com/ZAn5vTFD/multiple-threads-and-scardgetstatuschange)?
>
>
> Exact. Using the same hContext in different threads may lead to dead locks.
>
> Maskim, can you try again on Windows but using 2 different hContext (SCardEstablishContext) in the 2 threads?
>
> Thanks
>
>
> --
>  Dr. Ludovic Rousseau
>
> _______________________________________________
> Pcsclite-muscle mailing list
> [hidden email]
> http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle

_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle
Reply | Threaded
Open this post in threaded view
|

Re: Difference from Windows' implementation with regard to PC/SC shared mode

Ludovic Rousseau
Hello,

2016-10-31 22:26 GMT+01:00 Maksim Ivanov <[hidden email]>:

> Hello,
>
>
> On Wed, Oct 26, 2016 at 6:29 PM, Ludovic Rousseau
> <[hidden email]> wrote:
>> Maskim, can you try again on Windows but using 2 different hContext
>> (SCardEstablishContext) in the 2 threads?
>
> Sorry, I don't have a Windows device at hand. I'll try to find one and
> see whether I can reproduce the issue.
>
> I based my message on a report from one of our partners.
>
> Though sorry for not mentioning explicitly that I didn't have a
> reproducible test case.

Without confirmation of this difference I reverted the change in the
documentation.
https://github.com/LudovicRousseau/PCSC/commit/5c7f9665358b55d320cfefb2276348a53a59da33

Next time please provide a sample code (in C, Python or whatever [1])
to exhibit the behaviour difference.

Bye

[1] https://ludovicrousseau.blogspot.fr/2010/04/pcsc-sample-in-different-languages.html

--
 Dr. Ludovic Rousseau

_______________________________________________
Pcsclite-muscle mailing list
[hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pcsclite-muscle