OpenJdk 7 and OpenJdk 8 miss-report the os.arch field and cause java apps to crash.

Bug #1438575 reported by bugproxy
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
openjdk-7 (Ubuntu)
Fix Released
Undecided
Unassigned
openjdk-8 (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Problem Description
=======================================
OpenJdk 7 and OpenJdk 8 miss report the os.arch field and cause java apps to crash.

When we run under OpenJDK on a ubuntu ppc64el system the os.arch system properites gets reported as ppc64.

This causes multiple java libraries to load the wrong native architecture modules as it thinks this is a big endian machine, rather than a ppc64le machine.

---uname output---
Linux tulgpu002 3.16.0-30-generic #40-Ubuntu SMP Mon Jan 12 22:07:11 UTC 2015 ppc64le ppc64le ppc64le GNU/Linux

Machine Type = 8247-42L

Steps to Reproduce
===================================================
make sure an openjdk is installed.
sudo apt-get install openjdk-7-jdk

Create a very simple java properties dumper.

cat >sysprop.java <<EOF
class sysprop{
  public static void main(String[] args){
    System.getProperties().list(System.out);
   }
}
EOF

and run it and look for the os.arch output.

javac sysprop.java

ralphbel@tulgpu002:~/java$ java sysprop | grep arch
os.arch=ppc64
sun.arch.data.model=64

== Comment: #2 - Ralph E. Bellofatto <email address hidden> - 2015-03-17 05:39:29 ==
Acutally this is ubuntu 14.10.

ralphbel@tulgpu002:~/java$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.10
Release: 14.10
Codename: utopic

I suspect this problem also exists on the ubuntu 14.04 releases although we have not tried that yet...

== Comment: #3 - Ralph E. Bellofatto <email address hidden> - 2015-03-17 05:51:04 ==
more information on the package we are using:

ralphbel@tulgpu002:~/jnr-ffi$ apt-cache policy openjdk-7-jdk
openjdk-7-jdk:
  Installed: 7u75-2.5.4-1~utopic1
and
ralphbel@tulgpu002:~/jnr-ffi$ apt-cache policy openjdk-8-jdk
openjdk-8-jdk:
  Installed: 8u40~b09-1

== Comment: #4 - Ralph E. Bellofatto <email address hidden> - 2015-03-18 15:04:51 ==
This is an interesting comment in the openJDK bugs database:

****************************
https://bugs.openjdk.java.net/browse/JDK-8073139
****************************

apparently there was a decision to NOT give the architecture a unique name, and that is inconstant with other JDK/JRE's, and it breaks a LOT of code.

bugproxy (bugproxy)
tags: added: architecture-ppc64le bugnameltc-122843 severity-critical targetmilestone-inin1404
Revision history for this message
bugproxy (bugproxy) wrote : Comment bridged from LTC Bugzilla

------- Comment From <email address hidden> 2015-03-31 11:22 EDT-------
This has been already handled for RedHat and patches are already submitted:

See: http://mail.openjdk.java.net/pipermail/hotspot-dev/2015-February/017266.html
> I now have these changes working on 8u31:
>
> http://cr.openjdk.java.net/~andrew/rh1191652/root
> http://cr.openjdk.java.net/~andrew/rh1191652/jdk

Is this good enough for Ubuntu integration ?

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. It seems that your bug report is not filed about a specific source package though, rather it is just filed against Ubuntu in general. It is important that bug reports be filed about source packages so that people interested in the package can find the bugs about it. You can find some hints about determining what package your bug might be about at https://wiki.ubuntu.com/Bugs/FindRightPackage. You might also ask for help in the #ubuntu-bugs irc channel on Freenode.

To change the source package that this bug is filed about visit https://bugs.launchpad.net/ubuntu/+bug/1438575/+editstatus and add the package name in the text box next to the word Package.

[This is an automated message. I apologize if it reached you inappropriately; please just reply to this message indicating so.]

tags: added: bot-comment
Luciano Chavez (lnx1138)
affects: ubuntu → openjdk-7 (Ubuntu)
Revision history for this message
Matthias Klose (doko) wrote :

there is currently no working patch for openjdk-7 afaics

Changed in openjdk-7 (Ubuntu):
status: New → Incomplete
Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2015-04-15 21:40 EDT-------
(In reply to comment #13)
> there is currently no working patch for openjdk-7 afaics

Andrew Hughes made those patches for OpenJDK 7 and applied to IcedTea master repository, it's going to be available on IcedTea 2.6 release.

There's a bug report at http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=2236

The patch itself was not added to the bug report but can be fetched from the following 2 commits:
http://icedtea.classpath.org//hg/icedtea7-forest/hotspot?cmd=changeset;node=4fdaf786d977
http://icedtea.classpath.org//hg/icedtea7-forest/jdk?cmd=changeset;node=bf4c2a6c354d

AFAIK RedHat's patch is the same as the ones available in both Fedora and CentOS sources.

Fedora: http://koji.fedoraproject.org/koji/buildinfo?buildID=628482 (fetch, expand the source, and look for rh1191652-*.patch)

CentOS:
https://git.centos.org/blob/rpms!java-1.7.0-openjdk/3c3d8d7cb372ac0351f4881d0e50a1185d7e9466/SOURCES!rh1191652-jdk.patch
https://git.centos.org/blob/rpms!java-1.7.0-openjdk/3c3d8d7cb372ac0351f4881d0e50a1185d7e9466/SOURCES!rh1191652-hotspot.patch

Regards,
Tiago

Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2015-04-28 03:57 EDT-------
Just a quick update to let you know that IcedTea 2.6 release should happen in a month or so according to its maintainer.

Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2015-07-20 09:22 EDT-------
Are patches mentioned in comment#15 good enough for integration ?

Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Looks like openjdk-7 in wily now includes this. Marking as fix released.

Changed in openjdk-7 (Ubuntu):
status: Incomplete → Fix Released
Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2015-09-16 13:52 EDT-------
Hello Canonical,

This same issue has also been reported on 15.04 by a different originator in a different LTC bug. In addition, the originator of this bug also states that the same fix is needed in 14.04. Can we please get tracks opened for both these releases in bug 1438575 to deliver the fixes there as well?

Revision history for this message
Luciano Chavez (lnx1138) wrote :

Hello Tiago,

Do you recall a workaround for this issue?

Revision history for this message
Tiago Stürmer Daitx (tdaitx) wrote :

Hi Luciano,

My apologies, while I'm subscribed to this bug for some reason I missed the message from your last comment. To answer your question: besides re-compiling openjdk 7 on their own, there is not much a user can do (* see bellow for a hack-ish way)

This issue has been fixed in IcedTea 2.6+ which is only available for Wily.

-> 2.6.1 (Wily)
$ java -XshowSettings -version 2>&1 | grep -e IcedTea -e os.arch -e sun.boot.library.path
    os.arch = ppc64le
    sun.boot.library.path = /usr/lib/jvm/java-7-openjdk-ppc64el/jre/lib/ppc64le
OpenJDK Runtime Environment (IcedTea 2.6.1) (7u85-2.6.1-5)

-> 2.5.6 (Vivid, Trusty)
$ java -XshowSettings -version 2>&1 | grep -e IcedTea -e os.arch -e sun.boot.library.path
    os.arch = ppc64
    sun.boot.library.path = /usr/lib/jvm/java-7-openjdk-ppc64el/jre/lib/ppc64
OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6-0ubuntu1.15.04.1)

I will check if we can update Vivid and Trusty to 2.6.x in the upcoming IcedTea 2.6.2 release that I'm working on, otherwise I will provide an SRU with the patch to fix this.

** Ugly hack **
Remember: use at your own risk, don't try it at home, keep the kids away, yada yada. ;-)

It is possible to get os.arch to return "ppc64le" by modifying the libjava.so file in jre/lib/ppc64

The following information is valid for Vivid, I haven't checked but Trusty offsets might be different.
Using a hex editor (eg. hexedit), go to position 0x2B938, where it should show in ASCII "little..ppc64...GNOME_DESKTOP_SESSION_ID" and modify the 'ppc64' entry to 'ppc64le' (overwriting 2 null bytes).

$ cmp -lb libjava.so.orig libjava.so
178494 0 ^@ 154 l
178495 0 ^@ 145 e

$ java -XshowSettings -version 2>&1 | grep -e IcedTea -e os.arch -e sun.boot.library.path
    os.arch = ppc64le
    sun.boot.library.path = /usr/lib/jvm/java-7-openjdk-ppc64el/jre/lib/ppc64
OpenJDK Runtime Environment (IcedTea 2.5.6) (7u79-2.5.6-0ubuntu1.15.04.1)

With that, programs that depend on os.arch might work as expected (I haven't test anything besides the -XshowSettings test above).

Depending on how the program behaves, you might also need to link the 'ppc64' lib arch dir to 'ppc64le', eg:
# cd /usr/lib/jvm/java-7-openjdk-ppc64el/jre/lib
# ln -s ppc64 ppc64le

If you do test this, let me know the results and what programs you tested it with. I'm a bit curious on how well it might work. =)

Revision history for this message
Matthias Klose (doko) wrote :

fixed in openjdk-8 as well

Changed in openjdk-8 (Ubuntu):
status: New → Fix Released
Revision history for this message
bugproxy (bugproxy) wrote :

------- Comment From <email address hidden> 2016-02-02 13:52 EDT-------
Hello,

Anyone know if this is fixed in Trusty yet? Thanks.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.