Bug 569803 - Cannot be made thread-safe when used by a library
Summary: Cannot be made thread-safe when used by a library
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: libgcrypt
Version: 13
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Tomas Mraz
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-03-02 13:31 UTC by Tim Waugh
Modified: 2011-06-03 12:47 UTC (History)
4 users (show)

Fixed In Version: gnutls-2.12.4-1.fc16
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-06-03 12:47:42 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
libgcrypt-invalidate-thread-cbs.patch (untested) (4.40 KB, patch)
2010-09-16 16:35 UTC, Tim Waugh
no flags Details | Diff
libgcrypt-invalidate-thread-cbs.patch (more work needed by upstream) (5.13 KB, patch)
2010-09-17 12:30 UTC, Tim Waugh
no flags Details | Diff
libgcrypt-use-pthread.patch (untested) (909 bytes, patch)
2010-09-17 16:27 UTC, Tim Waugh
no flags Details | Diff

Description Tim Waugh 2010-03-02 13:31:48 UTC
See this comment for a full explanation: https://bugzilla.redhat.com/show_bug.cgi?id=553834#c43

Comment 1 Tomas Mraz 2010-03-02 15:08:31 UTC
Reported upstream as:
https://bugs.g10code.com/gnupg/issue1197

Comment 2 Tim Waugh 2010-09-15 15:37:15 UTC
*ping*

Is anyone working on this?

Comment 3 Tim Waugh 2010-09-16 16:35:49 UTC
Created attachment 447791 [details]
libgcrypt-invalidate-thread-cbs.patch (untested)

Here is an untested patch to demonstrate what I think might be one approach to the problem.

When GCRYCTL_SET_THREAD_CBS is called and we already have an interface installed, a copy is made of this new interface.  If it is called several times by different libraries, we have several different interfaces to choose from.

When a library is dlclosed, a new API command GCRYCTL_INVALIDATE_THREAD_CBS should be called with the same function pointers as originally given to GCRYCTL_SET_THREAD_CBS.  If the invalidated interface is the one in use, this has the effect of switching to one (and initialising) of the other available interfaces.

Is this a viable approach?

Comment 4 Tomas Mraz 2010-09-16 16:52:44 UTC
Tim, the best thing would be to discuss it with the libgcrypt upstream. I do not have much influence on it.

Comment 5 Tim Waugh 2010-09-17 12:30:13 UTC
Created attachment 447988 [details]
libgcrypt-invalidate-thread-cbs.patch (more work needed by upstream)

Here is as far as I can go with this patch.

The problem I've come up against is that libgcrypt doesn't have any way of simply re-initialising the mutexes it uses.  Basically, it has no concept of how to behave if the mutexes created by the calling library become invalid.

I don't know who/how to contact upstream so hopefully I can leave this with you.

In the mean time I think I'll need to get libcups to serialize all calls to gnutls. :-(((

Comment 6 Joe Orton 2010-09-17 12:47:30 UTC
The gcrypt ath_ stuff is designed to cope with the long-since-obsolete user-space thread libraries like GNU pth and IMO should simply be ripped out and hard-coded to use POSIX (or whatever the platforms supports).

At minimum we could make it DTRT by default and ignore GCRYCTL_SET_THREAD_CBS completely.

Comment 7 Tim Waugh 2010-09-17 15:26:44 UTC
Joe: absolutely agree.

Comment 8 Tim Waugh 2010-09-17 16:27:56 UTC
Created attachment 448055 [details]
libgcrypt-use-pthread.patch (untested)

Perhaps something along these lines could be applied to the Fedora package as a work-around?

Comment 9 Bug Zapper 2011-06-02 16:21:19 UTC
This message is a reminder that Fedora 13 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 13.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '13'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 13's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 13 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 10 Tim Waugh 2011-06-03 12:47:42 UTC
Looks like this is fixed in gnutls-2.12.x?


Note You need to log in before you can comment on or make changes to this bug.