Bug 599227 - mingw <pthread.h> is broken
mingw <pthread.h> is broken
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: mingw32-pthreads (Show other bugs)
rawhide
All Linux
low Severity medium
: ---
: ---
Assigned To: Kalev Lember
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2010-06-02 17:40 EDT by Eric Blake
Modified: 2011-05-12 13:18 EDT (History)
8 users (show)

See Also:
Fixed In Version: mingw32-pthreads-2.8.0-15.20110511cvs.fc16
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-05-12 13:18:33 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Eric Blake 2010-06-02 17:40:19 EDT
Description of problem:
The cross-compilation header /usr/i686-pc-mingw32/sys-root/mingw/include/pthread.h, installed as part of the mingw32-pthreads package, has several coding bugs.

Version-Release number of selected component (if applicable):
mingw32-pthreads-2.8.0-10.fc13.noarch

How reproducible:
Always


Steps to Reproduce:
1. Try cross-compiling any code that uses localtime_r with a second argument with side effects, or try calling (localtime_r)(arg1,arg2).
2. Try cross-compiling any project that uses gnulib's <time.h> replacement header (libvirt is an example project; it includes a ./autobuild.sh script that will automatically try a mingw cross-compilation, if you have installed a mingw portablexdr library, although that library is not yet part of fedora).
  
Actual results:
The definition of localtime_r is broken, because it evaluates the second argument twice.  And, since POSIX allows one to #undef localtime_r, but there is no localtime_r function in the library, you get a link failure if you bypass the function-like macro.  Finally, the pthreads-win32 library made the mistake of installing <config.h>, which is asking for namespace collision with most other autotooled packages.

Expected results:
<pthread.h> should not define any *_r functions, nor should it interfere with a proper <time.h>.  Also, the library should not install <config.h>, but should instead modify its installed headers to be self-contained.

Additional info:
See this thread on bug-gnulib for more details:
http://lists.gnu.org/archive/html/bug-gnulib/2010-06/msg00007.html
Comment 1 Ryan O'Hara 2010-07-14 17:08:10 EDT
I recently came across this bug when trying to compile libcheck under mingw32, which choked on the localtime_r problem described in comment #1.
Comment 2 Erik van Pienbroek 2011-01-28 13:37:53 EST
Do you happen to know if these issues have been resolved upstream already? There has been activity in upstreams CVS repo to add support for mingw-w64 and possibly other fixes. See http://sourceforge.net/apps/trac/mingw-w64/wiki/Compile%20pthreads for details.

On that link there also are patches to fix the config.h issue which you mentioned. For the new cross compiler framework which I mentioned in your other bugreport (bug 599567) I have those patches already applied.

If you want to test this new version of mingw32-pthreads you can use the testing repository for the new cross compiler framework. Details for that can be found at https://fedoraproject.org/wiki/MinGW/CrossCompilerFramework
Comment 3 Kalev Lember 2011-05-12 03:08:56 EDT
(In reply to comment #0)
[snip]
> Finally, the pthreads-win32 library made the mistake
> of installing <config.h>, which is asking for namespace collision with most
> other autotooled packages.
> 
> Expected results:
[snip]
> Also, the library should not install <config.h>, but should
> instead modify its installed headers to be self-contained.

I gave a stab at fixing the config.h issue. In rawhide pthreads.h no longer includes config.h and both config.h and its other private headers are no longer installed.

The fix is in mingw32-pthreads-2.8.0-14.fc16

http://pkgs.fedoraproject.org/gitweb/?p=mingw32-pthreads.git;a=blobdiff;f=mingw32-pthreads.spec;h=4b7aaff11c12bb7df614ea7f4d2a0af35aa66d76;hp=e6dbf82ceefe2a5b5ea4ca9164a1be94ae046c56;hb=7b7cbed7d5e5a0ec8c68a42e280e8bc74d01a734;hpb=dc57f4600486bd31e906493e4dcec1396d33e5a0
Comment 4 Kalev Lember 2011-05-12 03:56:28 EDT
It would also appear that in CVS HEAD localtime_r and other *_r definitions are gone from pthreads.h; perhaps we should consider packaging up a snapshot.

Anyone interested in talking to upstream and asking when they are going to make a new release?
Comment 5 Erik van Pienbroek 2011-05-12 12:56:32 EDT
After some discussion with Kalev on IRC I think it's a good idea to update the mingw32-pthreads package in Fedora to the latest CVS version. That way we should also be ready with a compatible version for when mingw-w64 will be introduced in Fedora 16
Comment 6 Kalev Lember 2011-05-12 13:18:33 EDT
I just built mingw32-pthreads-2.8.0-15.20110511cvs.fc16 for rawhide, which should fix both the config.h issue by removing the header, and also remove the possibly conflicting localtime_r definition. I did some basic testing, but it would be very awesome if someone else could try it with a real world test case.

Closing the ticket.

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