Bug 14315

Summary: [3.4 only]: Java compiler is not parallel make safe
Product: gcc Reporter: H.J. Lu <hjl.tools>
Component: javaAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs, java-prs, mark
Priority: P2 Keywords: patch
Version: 3.4.0   
Target Milestone: 3.4.1   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2004-02-27 01:52:52
Attachments: proposed fix

Description H.J. Lu 2004-02-27 01:40:57 UTC
During bootstrap on a SMP machine, I got

/export/build/gnu/gcc-3.4-ia32e/build-ia32e-linux/gcc/gcj
-B/export/build/gnu/gcc-3.4-ia32e/build-ia32e-linux/ia32e-linux/libjava/
-B/export/build/gnu/gcc-3.4-ia32e/build-ia32e-linux/gcc/ --encoding=UTF-8
-Wno-deprecated -C -g -classpath '' -bootclasspath
/export/build/gnu/gcc-3.4-ia32e/build-ia32e-linux/ia32e-linux/libjava:/net/gnu/export/gnu/src/gcc-3.4/gcc/libjava
-d /export/build/gnu/gcc-3.4-ia32e/build-ia32e-linux/ia32e-linux/libjava
/net/gnu/export/gnu/src/gcc-3.4/gcc/libjava/java/util/regex/Pattern.java
/net/gnu/export/gnu/src/gcc-3.4/gcc/libjava/java/util/regex/Pattern.java: In
class `java.util.regex.Pattern':
/net/gnu/export/gnu/src/gcc-3.4/gcc/libjava/java/util/regex/Pattern.java: In
method `<clinit>()':
/net/gnu/export/gnu/src/gcc-3.4/gcc/libjava/java/util/regex/Pattern.java:1:
fatal error: can't create directory
/export/build/gnu/gcc-3.4-ia32e/build-ia32e-linux/ia32e-linux/libjava/java/util/regex:
File exists
compilation terminated.

The problem is

  while (1)
    {
      char *s = strchr (dname, sep);
      if (s == NULL)
        break;
      *s = '\0';
      if (stat (r, &sb) == -1
          /* Try to make it.  */
          && mkdir (r, 0755) == -1)
        fatal_error ("can't create directory %s: %m", r);
                                                                                
      *s = sep;
      /* Skip consecutive separators.  */
      for (dname = s + 1; *dname && *dname == sep; ++dname)
        ;
   }

in jcf-write.c. 'r' can be created between stat and mkdir.
Comment 1 Andrew Pinski 2004-02-27 01:52:52 UTC
confirmed.
Comment 2 Tom Tromey 2004-03-01 23:04:31 UTC
Created attachment 5840 [details]
proposed fix

Could you try the attached patch?
Comment 3 H.J. Lu 2004-03-03 16:12:31 UTC
The proposed patch works for me.
Comment 4 Andrew Pinski 2004-03-23 17:49:00 UTC
Patch posted here: <http://gcc.gnu.org/ml/gcc-patches/2004-03/msg01935.html>.
Comment 5 GCC Commits 2004-03-23 17:54:09 UTC
Subject: Bug 14315

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tromey@gcc.gnu.org	2004-03-23 17:54:03

Modified files:
	gcc/java       : ChangeLog jcf-write.c 

Log message:
	PR java/14315:
	* jcf-write.c (make_class_file_name): Don't report if mkdir
	failed with EEXIST.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&r1=1.1347&r2=1.1348
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/jcf-write.c.diff?cvsroot=gcc&r1=1.141&r2=1.142

Comment 6 Tom Tromey 2004-03-23 17:55:18 UTC
Fix checked in on trunk.
Comment 7 H.J. Lu 2004-04-27 18:04:08 UTC
Can we backport this patch to 3.4?
Comment 8 GCC Commits 2004-05-20 16:06:33 UTC
Subject: Bug 14315

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	hjl@gcc.gnu.org	2004-05-20 16:06:14

Modified files:
	gcc/java       : ChangeLog jcf-write.c 

Log message:
	2004-05-20  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR java/14315
	Backport from mainline:
	
	2004-03-23  Tom Tromey  <tromey@redhat.com>
	
	* jcf-write.c (make_class_file_name): Don't report if mkdir
	failed with EEXIST.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.1315.2.15&r2=1.1315.2.16
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/java/jcf-write.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.140&r2=1.140.4.1

Comment 9 Andrew Pinski 2004-05-20 16:11:12 UTC
Fixed.