RFR [XS] : 8175000 : jexec fails to execute simple helloworld.jar
Baesken, Matthias
matthias.baesken at sap.com
Wed Mar 1 16:07:35 UTC 2017
Hi Thomas , thanks for looking into it .
I suggest to handle the read issue in another bug because this one just deals with “jexec fails to execute simple helloworld.jar” .
( there seem to be a few other read(…) calls in the jdk code base to consider as well )
Can we push the existing change ?
Regards, Matthias
From: Thomas Stüfe [mailto:thomas.stuefe at gmail.com]
Sent: Mittwoch, 1. März 2017 12:47
To: Baesken, Matthias <matthias.baesken at sap.com>
Cc: core-libs-dev at openjdk.java.net; Simonis, Volker <volker.simonis at sap.com>
Subject: Re: RFR [XS] : 8175000 : jexec fails to execute simple helloworld.jar
Hi Matthias,
the fix makes sense, this is very clearly a bug.
I'd suggest a simpler fix though:
end -= 4; // make sure there are 4 bytes to read at start
- while (start < end) {
+ while (start <= end) {
Note that the code has a diffent bug too, very unlikely but not impossible to hit:
321 ssize_t count = read(fd, buf, CHUNK_SIZE);
322 if (count >= MIN_SIZE) {
We attempt to read CHUNK_SIZE bytes and require the read to have returned at least MIN_SIZE (something like 30ish bytes). If not, jexec fails.
read may have been interrupted (EINTR) or may have returned less bytes than MIN_SIZE, so it should read in a loop til eof or CHUNK_SIZE bytes are read.
Kind Regards, Thomas
On Wed, Mar 1, 2017 at 10:23 AM, Baesken, Matthias <matthias.baesken at sap.com<mailto:matthias.baesken at sap.com>> wrote:
Ping ...
Can I get a review please for the change ?
Thanks, Matthias
From: Baesken, Matthias
Sent: Donnerstag, 23. Februar 2017 12:28
To: 'core-libs-dev at openjdk.java.net<mailto:core-libs-dev at openjdk.java.net>' <core-libs-dev at openjdk.java.net<mailto:core-libs-dev at openjdk.java.net>>
Cc: Langer, Christoph <christoph.langer at sap.com<mailto:christoph.langer at sap.com>>; Erik Joelsson (erik.joelsson at oracle.com<mailto:erik.joelsson at oracle.com>) <erik.joelsson at oracle.com<mailto:erik.joelsson at oracle.com>>; 'Michel Trudeau' <michel.trudeau at oracle.com<mailto:michel.trudeau at oracle.com>>
Subject: RE: RFR [XS] : 8175000 : jexec fails to execute simple helloworld.jar
Here is the webrev for jdk9 :
http://cr.openjdk.java.net/~mbaesken/webrevs/8175000/
? And btw I really wonder - is jexec still needed in future jdk's like jdk10 ? Seems it is not used much .
?
In case jexec will stay in the jdk I might add a test for the tool as well, if there is interest ( could not really find one that tests execution of a simple jar-file with jexec).
Best regards, Matthias
From: Baesken, Matthias
Sent: Donnerstag, 23. Februar 2017 07:39
To: 'core-libs-dev at openjdk.java.net<mailto:core-libs-dev at openjdk.java.net>' <core-libs-dev at openjdk.java.net<mailto:core-libs-dev at openjdk.java.net><mailto:core-libs-dev at openjdk.java.net<mailto:core-libs-dev at openjdk.java.net>>>
Cc: Langer, Christoph <christoph.langer at sap.com<mailto:christoph.langer at sap.com><mailto:christoph.langer at sap.com<mailto:christoph.langer at sap.com>>>; Erik Joelsson (erik.joelsson at oracle.com<mailto:erik.joelsson at oracle.com><mailto:erik.joelsson at oracle.com<mailto:erik.joelsson at oracle.com>>) <erik.joelsson at oracle.com<mailto:erik.joelsson at oracle.com><mailto:erik.joelsson at oracle.com<mailto:erik.joelsson at oracle.com>>>
Subject: RE: RFR [XS] : 8175000 : jexec fails to execute simple helloworld.jar
Hello, probably I should add the info that the fix is needed in jdk9 as well , not only jdk10 .
Without the fix jdk9/10 show this error when executing a small example jar :
/myjdk9/images/jdk/lib/jexec /java_test/hellojar/helloworld.jar
invalid file (bad magic number): Exec format error
with the fix :
jdk/lib/jexec /java_test/hellojar/helloworld.jar
Hello world from a jar file
And btw I really wonder - is jexec still needed in future jdk's like jdk10 ? Seems it is not used much .
Best regards, Matthias
From: Baesken, Matthias
Sent: Mittwoch, 22. Februar 2017 18:16
To: core-libs-dev at openjdk.java.net<mailto:core-libs-dev at openjdk.java.net><mailto:core-libs-dev at openjdk.java.net<mailto:core-libs-dev at openjdk.java.net>>
Cc: Langer, Christoph <christoph.langer at sap.com<mailto:christoph.langer at sap.com><mailto:christoph.langer at sap.com<mailto:christoph.langer at sap.com>>>; Erik Joelsson (erik.joelsson at oracle.com<mailto:erik.joelsson at oracle.com><mailto:erik.joelsson at oracle.com<mailto:erik.joelsson at oracle.com>>) <erik.joelsson at oracle.com<mailto:erik.joelsson at oracle.com><mailto:erik.joelsson at oracle.com<mailto:erik.joelsson at oracle.com>>>
Subject: RFR [XS] : 8175000 : jexec fails to execute simple helloworld.jar
Hello , when looking into the jexec build I noticed that execution of a simple helloworld.jar with jexec does not work any more.
I did a little patch for this which adjusted the addition done with CR 8156478: 3 Buffer overrun defect groups in jexec.c<https://javapartner.oracle.com/mproxy/repository/technology/java2/jdk9/jdk/rev/4f96129b45ee> .
Could I have a review ( just a diff this time is provided because of infrastructure issues) for it ?
Thanks, Matthias
Bug :
https://bugs.openjdk.java.net/browse/JDK-8175000
Diff for jdk10 :
# HG changeset patch
# User mbaesken
# Date 1487782485 -3600
# Wed Feb 22 17:54:45 2017 +0100
# Node ID 93d55a711f3b1c3f282e6889c24d13f16d4a4548
# Parent 884872263accabd4ab68d005abd4e5393144aa4f
8175000: jexec fails to execute simple helloworld.jar
diff --git a/src/java.base/unix/native/launcher/jexec.c b/src/java.base/unix/native/launcher/jexec.c
--- a/src/java.base/unix/native/launcher/jexec.c
+++ b/src/java.base/unix/native/launcher/jexec.c
@@ -331,8 +331,9 @@
off_t end = start + xlen;
if (end <= count) {
- end -= 4; // make sure there are 4 bytes to read at start
- while (start < end) {
+ // make sure there are 4 bytes to read at start
+ end -= 3;
+ while ((start < end) && (start < count-3)) {
off_t xhid = SH(buf, start);
off_t xdlen = SH(buf, start + 2);
More information about the core-libs-dev
mailing list