[Bug pch/39492] New: Parallel compilation fail using PCH on Windows NT>= 5.0
agalkin at hypercom dot com
gcc-bugzilla@gcc.gnu.org
Wed Mar 18 13:09:00 GMT 2009
If two parallel GCC compilation processes, which use different PCH files, run
on Windows NT version 5 or newer (e.g. Win2K, WinXP, Vista) in the same session
then a race condition occurs, which most likely leads to "Access Denied" error.
This may happen even if different toolchains are used or different projects are
compiled at the same time.
As it appears, the problem occurs because MinGW host hooks implementation uses
a single session-wide name for memory mapping object.
My suggested solution is to append current GCC process ID to that name. This
makes the mapping name unique and avoids name collisions. Below is the patch
for GCC 4.3.2 source. Tested on WinXP. As I've checked the current GCC trunk,
it has the same issue.
--- gcc/config/i386/host-mingw32.c 2007-08-02 13:49:31.000000000 +0300
+++ gcc/config/i386/host-mingw32.c 2009-03-17 21:00:21.422434682 +0200
@@ -120,8 +120,19 @@
namespace when running an application in a Terminal Server
session. This causes failure since, by default, applications
don't get SeCreateGlobalPrivilege. We don't need global
- memory sharing so explicitly put object into Local namespace. */
- const char object_name[] = "Local\\MinGWGCCPCH";
+ memory sharing so explicitly put object into Local namespace.
+
+ There is also another issue, which appears if multiple concurrent
+ GCC processes use PCH functionality. MapViewOfFileEx returns
+ "Access Denied" error. So we need to make the session-wide mapping
+ name unique. Let's use current process ID for that. */
+ const char object_name_prefix[] = "Local\\MinGWGCCPCH-";
+
+ /* Alloc enough space for name prefix and max possible DWORD decimal
+ representation */
+ char object_name[sizeof( object_name_prefix ) + 10];
+ snprintf (object_name, sizeof(object_name), "%s%lu", object_name_prefix,
+ GetCurrentProcessId());
/* However, the documentation for CreateFileMapping says that on NT4
and earlier, backslashes are invalid in object name. So, we need
--
Summary: Parallel compilation fail using PCH on Windows NT>= 5.0
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: pch
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: agalkin at hypercom dot com
GCC build triplet: any
GCC host triplet: i686-pc-mingw32
GCC target triplet: any
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39492
More information about the Gcc-bugs
mailing list