Bug#833933: openjdk-7: jamvm is broken due to missing native methods in sun.misc.Unsafe

2016-08-10 Thread Tiago Daitx
Patch attached

On Wed, Aug 10, 2016 at 11:44 AM, Tiago Stürmer Daitx
 wrote:
> Source: openjdk-7
> Version: 7u111-2.6.7-1
> Severity: important
>
> Dear Maintainer,
>
> [Issue]
> The fix of OpenJDK's bug 8158260
> (http://icedtea.classpath.org/hg/release/icedtea7-forest-2.6/hotspot/rev/4f8cbd54a9c6)
> introduced 2 new native methods to the sun.misc.Unsafe class:
> isBigEndian0 and unalignedAccess0.
>
> This completely broke JamVM and as of now it is impossible to start a
> jamvm session.
>
> jtreg summary results for OpenJDK 7:
> hotspot - Test results: passed: 5; failed: 309; error: 7
> langtools - Test results: passed: 374; failed: 1,593; error: 1
>
> Error output from a hotspot testcase:
> --System.err:(6/344)--
> Error initialising VM (initialiseMainThread)
> Check the README for compatible class-libraries/versions
> Exception occurred while printing exception
> (java/lang/NullPointerException)...
> Original exception was java/lang/UnsatisfiedLinkError
> Error: Could not create the Java Virtual Machine.
> Error: A fatal exception has occurred. Program will exit.
> result: Failed. Unexpected exit from test [exit code: 1]
>
> Running java -jamvm -version fails the same way.
>
> [Fix]
> The simple fix is to add both methods to the natives.c file in the
> classlib/openjdk directory.
>
> I have tested this with IcedTea 2.6.7 and now jtreg passes:
> hotspot - Test results: passed: 220; failed: 90; error: 11
> langtools - Test results: passed: 1,901; failed: 65; error: 2
>
> I have reported this upstream at
> https://sourceforge.net/p/jamvm/code/merge-requests/1/ and it is now
> waiting review.
>
> Also reported for IcedTea 2.6.7 at
> http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=3134
>
> -- System Information:
> Debian Release: stretch/sid
>   APT prefers xenial-updates
>   APT policy: (4000, 'xenial-updates'), (4000, 'xenial-security'), (4000, 
> 'xenial-backports'), (4000, 'xenial')
> Architecture: amd64 (x86_64)
> Foreign Architectures: i386
>
> Kernel: Linux 4.4.0-31-generic (SMP w/4 CPU cores)
> Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
> Shell: /bin/sh linked to /bin/dash
> Init: systemd (via /run/systemd/system)
>



-- 
Tiago Stürmer Daitx
Software Engineer
tiago.da...@canonical.com

PGP Key: 4096R/F5B213BE (hkp://keyserver.ubuntu.com)
Fingerprint = 45D0 FE5A 8109 1E91 866E  8CA4 1931 8D5E F5B2 13BE
Description: Adds Unsafe methods from S8158260
 In order to fix the PPC64 bug S8158260 two new native methods were
 added to sun.misc.Unsafe: isBigEndian0 and unalignedAcces0.
 Both were added by the following commit:
 http://icedtea.classpath.org/hg/release/icedtea7-forest-2.6/hotspot/rev/4f8cbd54a9c6
 .
 This patch adds those methods to the JAMVM being used by IcedTea.
Author: Tiago Stürmer Daitx 
Bug: https://sourceforge.net/p/jamvm/code/merge-requests/1/
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=833933
Bug-IcedTea: http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=3134
Bug-Ubuntu: https://bugs.launchpad.net/openjdk/+bug/1611598
Last-Update: 2016-08-09
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- /dev/null
+++ b/patches/jamvm/8158260-fix.patch
@@ -0,0 +1,36 @@
+--- jamvm.orig/jamvm/src/classlib/openjdk/natives.c	2014-03-24 21:34:58.0 -0300
 jamvm/jamvm/src/classlib/openjdk/natives.c	2016-08-09 19:26:36.205775539 -0300
+@@ -34,6 +33,7 @@
+ #include "reflect.h"
+ #include "natives.h"
+ #include "openjdk.h"
++#include "properties.h"
+ #include "trace.h"
+ 
+ int classlibInitialiseNatives() {
+@@ -470,6 +465,16 @@
+ return ostack;
+ }
+ 
++uintptr_t *isBigEndian0(Class *clazz, MethodBlock *mb, uintptr_t *ostack) {
++*ostack++ = IS_BIG_ENDIAN;
++return ostack;
++}
++
++uintptr_t *unalignedAccess0(Class *clazz, MethodBlock *mb, uintptr_t *ostack) {
++*ostack++ = FALSE;
++return ostack;
++}
++
+ VMMethod sun_misc_unsafe[] = {
+ {"registerNatives","()V", unsafeRegisterNatives},
+ {"objectFieldOffset",  "(Ljava/lang/reflect/Field;)J",
+@@ -569,6 +574,8 @@
+ {"fullFence",  "()V", fullFence},
+ {"loadFence",  "()V", loadFence},
+ {"storeFence", "()V", storeFence},
++{"isBigEndian0",   "()Z", isBigEndian0},
++{"unalignedAccess0",   "()Z", unalignedAccess0},
+ {NULL, NULL, NULL}
+ };
+ 
--- a/Makefile.am
+++ b/Makefile.am
@@ -404,7 +404,8 @@ endif
 if BUILD_JAMVM
 ICEDTEA_PATCHES += \
 	patches/jamvm/noexecstack.patch \
-	patches/jamvm/pr2665.patch
+	patches/jamvm/pr2665.patch \
+	patches/jamvm/8158260-fix.patch
 endif
 
 if ENABLE_NSS


Bug#833933: openjdk-7: jamvm is broken due to missing native methods in sun.misc.Unsafe

2016-08-10 Thread Tiago Stürmer Daitx
Source: openjdk-7
Version: 7u111-2.6.7-1
Severity: important

Dear Maintainer,

[Issue]
The fix of OpenJDK's bug 8158260
(http://icedtea.classpath.org/hg/release/icedtea7-forest-2.6/hotspot/rev/4f8cbd54a9c6)
introduced 2 new native methods to the sun.misc.Unsafe class:
isBigEndian0 and unalignedAccess0.

This completely broke JamVM and as of now it is impossible to start a
jamvm session.

jtreg summary results for OpenJDK 7:
hotspot - Test results: passed: 5; failed: 309; error: 7
langtools - Test results: passed: 374; failed: 1,593; error: 1

Error output from a hotspot testcase:
--System.err:(6/344)--
Error initialising VM (initialiseMainThread)
Check the README for compatible class-libraries/versions
Exception occurred while printing exception
(java/lang/NullPointerException)...
Original exception was java/lang/UnsatisfiedLinkError
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
result: Failed. Unexpected exit from test [exit code: 1]

Running java -jamvm -version fails the same way.

[Fix]
The simple fix is to add both methods to the natives.c file in the
classlib/openjdk directory.

I have tested this with IcedTea 2.6.7 and now jtreg passes:
hotspot - Test results: passed: 220; failed: 90; error: 11
langtools - Test results: passed: 1,901; failed: 65; error: 2

I have reported this upstream at
https://sourceforge.net/p/jamvm/code/merge-requests/1/ and it is now
waiting review.

Also reported for IcedTea 2.6.7 at
http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=3134

-- System Information:
Debian Release: stretch/sid
  APT prefers xenial-updates
  APT policy: (4000, 'xenial-updates'), (4000, 'xenial-security'), (4000, 
'xenial-backports'), (4000, 'xenial')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.4.0-31-generic (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)