Bug 39177 - trunk revision 144128 - jar: internal error: java.lang.NullPointerException
Summary: trunk revision 144128 - jar: internal error: java.lang.NullPointerException
Status: RESOLVED FIXED
Alias: None
Product: classpath
Classification: Unclassified
Component: cp-tools (show other bugs)
Version: 0.98
: P3 blocker
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 41768 42849 53400 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-02-13 13:57 UTC by Rob
Modified: 2012-05-19 13:50 UTC (History)
9 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-10-08 11:29:20


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rob 2009-02-13 13:57:34 UTC
I installed trunk revision 144128 but it's 'gjar' is broken and
causes later revisions of gcc to be un-buildable.

# gjar --version
jar (GNU Classpath) 0.98-pre

# find --version
find (GNU findutils) 4.4.0


Installed GCC:

# gcc -v
Using built-in specs.
Target: i386-pc-solaris2.11
Configured with: ../gcc_trunk/configure --build=i386-pc-solaris2.11 --target=i386-pc-solaris2.11 --enable-languages=ada,c,c++,fortran,java,objc,obj-c++ --enable-shared --disable-static --enable-multilib --enable-decimal-float --with-long-double-128 --with-included-gettext --enable-stage1-checking --enable-checking=release --with-tune=k8 --with-cpu=k8 --with-arch=k8 --with-gnu-as --with-as=/usr/local/bin/as --without-gnu-ld --with-ld=/usr/bin/ld --with-gmp=/usr/local --with-mpfr=/usr/local --without-ppl
Thread model: posix
gcc version 4.4.0 20090212 (experimental) [trunk revision 144128] (GCC) 


Building GCC:

# gcc/xgcc -v
Using built-in specs.
Target: i386-pc-solaris2.11
Configured with: ../gcc_trunk/configure --build=i386-pc-solaris2.11 --target=i386-pc-solaris2.11 --enable-languages=ada,c,c++,fortran,java,objc,obj-c++ --enable-shared --disable-static --enable-multilib --enable-decimal-float --with-long-double-128 --with-included-gettext --enable-stage1-checking --enable-checking=release --with-tune=k8 --with-cpu=k8 --with-arch=k8 --with-gnu-as --with-as=/usr/local/bin/as --with-gnu-ld --with-ld=/usr/local/bin/ld --with-gmp=/usr/local --with-mpfr=/usr/local --without-ppl
Thread model: posix
gcc version 4.4.0 20090213 (experimental) [trunk revision 144149] (GCC) 


The build breaks here:

# gmake
(many hours)
here=`pwd`; cd ../../../../gcc_trunk/libjava/classpath/lib; \
find gnu java javax org sun -name .svn -prune -o -name '*.class' -print | \
gjar -cfM@ $here/libgcj-4.4.0.jar
jar: internal error:
java.lang.NullPointerException
   at gnu.classpath.tools.jar.Creator.writeCommandLineEntries(Creator.java:226)
   at gnu.classpath.tools.jar.Creator.run(Creator.java:244)
   at gnu.classpath.tools.jar.Main.run(Main.java:276)
   at gnu.classpath.tools.jar.Main.main(Main.java:284)
gmake[5]: *** [libgcj-4.4.0.jar] Error 1
gmake[5]: Leaving directory `/usr/share/src/gcc_build/i386-pc-solaris2.11/amd64/libjava'
gmake[4]: *** [all-recursive] Error 1
gmake[4]: Leaving directory `/usr/share/src/gcc_build/i386-pc-solaris2.11/amd64/libjava'
gmake[3]: *** [multi-do] Error 1
gmake[3]: Leaving directory `/usr/share/src/gcc_build/i386-pc-solaris2.11/libjava'
gmake[2]: *** [all-multi] Error 2
gmake[2]: Leaving directory `/usr/share/src/gcc_build/i386-pc-solaris2.11/libjava'
gmake[1]: *** [all-target-libjava] Error 2
gmake[1]: Leaving directory `/usr/share/src/gcc_build'
gmake: *** [all] Error 2
#

Rob
Comment 1 Rob 2009-02-16 23:07:14 UTC
This Bug stems from the setting of a new signal handler in 
GC_SysVGetDataStart() and the SIGSEGV is not getting caught.

../gcc_trunk/boehm-gc/os_dep.c :
...
    GC_setup_temporary_fault_handler();
    if (SETJMP(GC_jmp_buf) == 0) {
    	/* Try writing to the address.	*/
    	*result = *result;                    /* SIGSEGV */
        GC_reset_fault_handler();
    } else {
...

A quick workaround is to delete or rename your 'gjar' before
gcc's configury detects it. The gcc scripts will workaround
the absence of 'gjar' during the build. 

Rob
Comment 2 Rob 2009-02-19 00:01:07 UTC
I am reducing this from a "BLOCKER" only because there is a simple
'workaround' (and no 'fix') that allows one to easily continue the
build without any modification to the source. Lowered to "CRITICAL".

Rob
Comment 3 Andreas Jaeger 2009-10-08 08:33:30 UTC
Same problem on my x86_64-linux-gnu system.
Comment 4 Richard Biener 2009-10-08 11:29:19 UTC
Err, libjava/classpath/tools/gnu/classpath/tools/jar/Creator.java is just
complete bullshit.  Citing:

  protected Manifest createManifest(Main parameters)
    throws IOException
  {
    if (! parameters.wantManifest)
      return null;
    if (parameters.manifestFile != null)
      {
        // User specified a manifest file.
        InputStream contents = new FileInputStream(parameters.manifestFile);
        return new Manifest(contents);
      }
    return new Manifest();
  }

  protected void writeCommandLineEntries(Main parameters, OutputStream os)
    throws IOException
  {
    manifest = createManifest(parameters);
    /* If no version is specified, provide the same manifest version default
     * as Sun's jar tool */
    Attributes attr = manifest.getMainAttributes();

WTF do you expect to happen when createManifest returns NULL?  Well, a crash.

Simpler testcase:

> gjar-4.4 -cfM -
jar: internal error:
java.lang.NullPointerException
   at gnu.classpath.tools.jar.Creator.writeCommandLineEntries(Creator.java:219)
   at gnu.classpath.tools.jar.Creator.run(Creator.java:244)
   at gnu.classpath.tools.jar.Main.run(Main.java:276)
   at gnu.classpath.tools.jar.Main.main(Main.java:284)


Diff between what is in gcc 4.3 and what is in gcc 4.4:

@@ -222,9 +214,15 @@
     throws IOException
   {
     manifest = createManifest(parameters);
+    /* If no version is specified, provide the same manifest version default
+     * as Sun's jar tool */
+    Attributes attr = manifest.getMainAttributes();
+    if (attr.getValue(Attributes.Name.MANIFEST_VERSION) == null)
+      attr.putValue(Attributes.Name.MANIFEST_VERSION.toString(), "1.0");
+    attr.putValue("Created-By", System.getProperty("java.version") +
+                 " (" + System.getProperty("java.vendor") + ")");


oh, really?  Gosh.

So, who owns that brown paperbag?
Comment 5 Richard Biener 2009-10-08 11:31:29 UTC
Same code in GCC trunk.  This is a major regression to classpath 0.96.
Comment 6 Richard Biener 2009-10-08 11:32:53 UTC
I guess a simple

 if (parameters.manifestFile)
   {

   }

around that offending change would fix it.  But the way classpath is handled
inside the gcc tree is very unfriendly to simple changes.  Tom, can you
get this fixed and installed on the 4.4 branch and trunk?
Comment 7 Richard Biener 2009-10-08 13:15:31 UTC
This kind of fix works for me.
Comment 8 Rob 2009-10-10 21:00:11 UTC
(In reply to comment #7)
> This kind of fix works for me.

I'll leave it (java) to the Experts, so if you like it, commit it.


The only useful comment I could make is that I filed this on "2009-02-13".

I described it as a "Blocker" or "Critical" and you describe this as a 
"major regression"; some eights months later we are here ...

Thanks for being the one to fix it,
Rob


Comment 9 Richard Biener 2009-10-21 11:22:32 UTC
*** Bug 41768 has been marked as a duplicate of this bug. ***
Comment 10 Richard Biener 2009-10-21 11:25:02 UTC
Looks like classpath development is dead.  I have a set of files I can drop
into the GCC repositories but am not prepared to do a proper classpath update
(nor doing the upstream fix).  openSUSE packages now have this fixed.
Comment 11 Andrew Haley 2009-10-21 12:38:07 UTC
Well, you can at least submit the same patch to classpath-patches, if you haven't done so already.  Maybe just Cc: classpath-patches when you submit the patch to java-patches.
Comment 12 rguenther@suse.de 2009-10-21 13:28:48 UTC
Subject: Re:  trunk revision 144128 - jar: internal error:
 java.lang.NullPointerException

On Wed, 21 Oct 2009, aph at gcc dot gnu dot org wrote:

> ------- Comment #11 from aph at gcc dot gnu dot org  2009-10-21 12:38 -------
> Well, you can at least submit the same patch to classpath-patches, if you
> haven't done so already.  Maybe just Cc: classpath-patches when you submit the
> patch to java-patches.

Done.
Comment 13 Richard Biener 2009-10-21 13:30:05 UTC
Oh, it's moderated.  Well, so much for the fish.
Comment 14 ronis 2009-10-21 15:18:13 UTC
From the discussion it sounds like this isn't going to make it into a released gcc any time soon.  Any chance someone could upload a set of patches that I can apply locally?
Comment 15 Richard Biener 2009-10-22 15:41:47 UTC
Subject: Bug 39177

Author: rguenth
Date: Thu Oct 22 15:41:32 2009
New Revision: 153461

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153461
Log:
2009-10-22  Richard Guenther  <rguenther@suse.de>

        PR cp-tools/39177 * tools/gnu/classpath/tools/jar/Creator.java
        (writeCommandLineEntries):
        Do not use uninitialized manifest.
        * tools/classes/gnu/classpath/tools/jar/Creator.class: Re-generated.

Modified:
    trunk/libjava/classpath/ChangeLog
    trunk/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Creator.class
    trunk/libjava/classpath/tools/gnu/classpath/tools/jar/Creator.java

Comment 16 Richard Biener 2009-10-22 15:51:04 UTC
Subject: Bug 39177

Author: rguenth
Date: Thu Oct 22 15:50:46 2009
New Revision: 153462

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=153462
Log:
2009-10-22  Richard Guenther  <rguenther@suse.de>

        PR cp-tools/39177
        * tools/gnu/classpath/tools/jar/Creator.java (writeCommandLineEntries):
        Do not use uninitialized manifest.
        * tools/classes/gnu/classpath/tools/jar/Creator.class: Re-generated.

Modified:
    branches/gcc-4_4-branch/libjava/classpath/ChangeLog
    branches/gcc-4_4-branch/libjava/classpath/tools/classes/gnu/classpath/tools/jar/Creator.class
    branches/gcc-4_4-branch/libjava/classpath/tools/gnu/classpath/tools/jar/Creator.java

Comment 17 Richard Biener 2009-10-22 15:51:11 UTC
Fixed in the GCC copy of classpath.
Comment 18 Andrew Haley 2010-01-04 10:46:39 UTC
revision 1.9774
date: 2009-10-22 16:51:18 +0000;  author: aph;  state: Exp;  lines: +12 -0;  commitid: 5aOqqFT1hGw5gy8u;
2009-10-22  Andrew Haley  <aph@redhat.com>

        * native/jni/native-lib/cpnet.c (cpnet_addMembership): Fix
        aliasing warning.
        (cpnet_dropMembership): Likewise.

2009-10-21  Richard Guenther  <rguenther@suse.de>

        PR cp-tools/39177
        * tools/gnu/classpath/tools/jar/Creator.java (writeCommandLineEntries):
        Do not use uninitialized manifest.
Comment 19 Richard Biener 2010-01-22 22:10:26 UTC
*** Bug 42849 has been marked as a duplicate of this bug. ***
Comment 20 Mark Wielaard 2012-05-19 13:50:25 UTC
*** Bug 53400 has been marked as a duplicate of this bug. ***