OpenSC / pkcs11-helper

Library that simplifies the interaction with PKCS#11 providers for end-user applications using a simple API and optional OpenSSL engine
Other
66 stars 43 forks source link

Avoid running the atfork handler during fork fixup #17

Closed frankmorgner closed 6 years ago

frankmorgner commented 6 years ago

fixes https://github.com/OpenSC/pkcs11-helper/issues/16

loskutov commented 6 years ago

It doesn't seem to help as __pkcs11h_forkFixup is called inside the child handler, but the deadlock happens earlier (inside the "prepare" handler).

frankmorgner commented 6 years ago

Thanks for the feedback, I've changed the code accordingly.

loskutov commented 6 years ago

The deadlock is not caused by an already pending fork: the mutex is locked inside pkcs11h_addProvider for the first time, _g_pkcs11h_data->fork_pending isn't set and the deadlock still happens at the first fork inside C_Initialize.

alonbl commented 6 years ago

Hi, I will solve this at this weekend. Probably by assuming that recursive atfork will not happen. Thanks!

On Fri, Oct 19, 2018 at 3:54 PM Ignat Loskutov notifications@github.com wrote:

The deadlock is not caused by an already pending fork: the mutex is locked inside pkcs11h_addProvider https://github.com/OpenSC/pkcs11-helper/blob/pkcs11-helper-1.25.1/lib/pkcs11h-core.c#L702 for the first time, _g_pkcs11h_data->fork_pending isn't set and the deadlock still happens at the first fork inside C_Initialize.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/OpenSC/pkcs11-helper/pull/17#issuecomment-431353184, or mute the thread https://github.com/notifications/unsubscribe-auth/ABNIrSx89K4hUmpcvlj5O1_W77PlH37Iks5umct1gaJpZM4XlCgX .

alonbl commented 6 years ago

Hi, Please checkout #18, I hope it will resolve this specific opensc issue, however, opensc will get C_Finalized within the C_Initialize at child, I hope it will not dead lock there. Thanks!