Page MenuHome GnuPG

Scdaemon, w32 hang if two assuan connections are made in parallel
Closed, ResolvedPublic


To reproduce open two console windows.

In Konsole 1:


In Konsole 2:


Konsole 2 hangs. All further attempts to connect to scdaemon hang until scdaemon
is killed.
My workaround is to close each connection to the agent in kleopatra before
issuing a new SCD command but that is very fragile imo.

Debug output is uneventful scdaemon loops the message:
2017-03-02 16:34:51 scdaemon[7944] DBG: enter: apdu_get_status: slot=0 hang=0
2017-03-02 16:34:51 scdaemon[7944] DBG: leave: apdu_get_status => sw=0x0 status=7
2017-03-02 16:34:51 scdaemon[7944] npth_pselect failed: Input/output error -
waiting 1s

But it does this even when its not hanging (only one connection active)

I've assigned this to werner because it's windows only.

Event Timeline

I doubt that this is Windows only. On Linux we use our own driver but on
Windows we have to resort to PC/SC. My educated guess is that we are in some
blocking system call which is not npth_unprotected.

Version information, please.

I cannot replicate this on GNU/Linux with PC/SC (by disable-ccid).
Anyway, I am looking into this issue:

npth_pselect failed: Input/output error - waiting 1s

It is selecting FD which is created by gnupg_create_pipe.

It seems npth_eselect is for network FDs.

How about this change?

diff --git a/scd/scdaemon.c b/scd/scdaemon.c
index f7e9f83b5..462ff1b3e 100644

  • a/scd/scdaemon.c

+++ b/scd/scdaemon.c
@@ -1291,7 +1291,7 @@ handle_connections (int listen_fd)

while (npth_sigev_get_pending(&signo))
  handle_signal (signo);


  • ret = npth_eselect (nfd+1, &read_fdset, NULL, NULL, t, NULL, NULL);

+ ret = npth_select (nfd+1, &read_fdset, NULL, NULL, t);

saved_errno = errno;


Version was 2.1.19 from the installer built by werner / the speedo system.

I'll try out the patch

With this patch the log message is different (No such file or directory). Hang
still happens.

2017-03-03 10:21:06 scdaemon[8604] DBG: enter: apdu_get_status: slot=0 hang=0
2017-03-03 10:21:06 scdaemon[8604] DBG: leave: apdu_get_status => sw=0x0 status=7
2017-03-03 10:21:06 scdaemon[8604] npth_pselect failed: No such file or
directory - waiting 1s

This patch tried to fix the issue:;a=commit;h=f9acc7d18bb90f47dafe7e32ae92f567756d6b12

I was wrong that PIPE can be select(2)-ed on Windows. This patch changes the
code so that it uses kill(2) on UNIX and SetEvent on Windows
to break the loop.

I've tried latest master and it no longer hangs for me.

Thanks. Changing the status to not-released as this is fixed.