Hello Baesken,

I have attached 8175000.patch to the bug report,
it includes Thomas' suggested fix + a test.

I have also tested it,  you may want to post it to corelibs-dev.
If posting a new webrev, please add the pipermail to the bug report,
http://mail.openjdk.java.net/pipermail/core-libs-dev/2017-March/046548.html

If there are no further changes, I don't need to see it, and you
can add me as a reviewer, and I don't need credit for the test.

As for jexec, it appears that only Linux supports this, and I am
uncertain who is using it in the Linux community.
Perhaps we should try deprecate it in jdk10.
Filed: https://bugs.openjdk.java.net/browse/JDK-8176066

Thanks
Kumar




On 3/1/2017 9:14 AM, Thomas Stüfe wrote:
Hi Matthias,

On Wed, Mar 1, 2017 at 5:07 PM, Baesken, Matthias <matthias.baes...@sap.com <mailto:matthias.baes...@sap.com>> wrote:

    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 ?


Not a Reviewer, so it is not for me to decide. Someone from core libs should look at this.

...Thomas

    Regards, Matthias

    *From:*Thomas Stüfe [mailto:thomas.stu...@gmail.com
    <mailto:thomas.stu...@gmail.com>]
    *Sent:* Mittwoch, 1. März 2017 12:47
    *To:* Baesken, Matthias <matthias.baes...@sap.com
    <mailto:matthias.baes...@sap.com>>
    *Cc:* core-libs-dev@openjdk.java.net
    <mailto:core-libs-dev@openjdk.java.net>; Simonis, Volker
    <volker.simo...@sap.com <mailto:volker.simo...@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.baes...@sap.com <mailto:matthias.baes...@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@openjdk.java.net
        <mailto:core-libs-dev@openjdk.java.net>'
        <core-libs-dev@openjdk.java.net
        <mailto:core-libs-dev@openjdk.java.net>>
        Cc: Langer, Christoph <christoph.lan...@sap.com
        <mailto:christoph.lan...@sap.com>>; Erik Joelsson
        (erik.joels...@oracle.com <mailto:erik.joels...@oracle.com>)
        <erik.joels...@oracle.com <mailto:erik.joels...@oracle.com>>;
        'Michel Trudeau' <michel.trud...@oracle.com
        <mailto:michel.trud...@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/
        <http://cr.openjdk.java.net/%7Embaesken/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@openjdk.java.net
        <mailto:core-libs-dev@openjdk.java.net>'
        <core-libs-dev@openjdk.java.net
        
<mailto:core-libs-dev@openjdk.java.net><mailto:core-libs-dev@openjdk.java.net
        <mailto:core-libs-dev@openjdk.java.net>>>

        Cc: Langer, Christoph <christoph.lan...@sap.com
        <mailto:christoph.lan...@sap.com><mailto:christoph.lan...@sap.com
        <mailto:christoph.lan...@sap.com>>>; Erik Joelsson
        (erik.joels...@oracle.com
        <mailto:erik.joels...@oracle.com><mailto:erik.joels...@oracle.com
        <mailto:erik.joels...@oracle.com>>) <erik.joels...@oracle.com
        <mailto:erik.joels...@oracle.com><mailto:erik.joels...@oracle.com
        <mailto:erik.joels...@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@openjdk.java.net
        
<mailto:core-libs-dev@openjdk.java.net><mailto:core-libs-dev@openjdk.java.net
        <mailto:core-libs-dev@openjdk.java.net>>
        Cc: Langer, Christoph <christoph.lan...@sap.com
        <mailto:christoph.lan...@sap.com><mailto:christoph.lan...@sap.com
        <mailto:christoph.lan...@sap.com>>>; Erik Joelsson
        (erik.joels...@oracle.com
        <mailto:erik.joels...@oracle.com><mailto:erik.joels...@oracle.com
        <mailto:erik.joels...@oracle.com>>) <erik.joels...@oracle.com
        <mailto:erik.joels...@oracle.com><mailto:erik.joels...@oracle.com
        <mailto:erik.joels...@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
        
<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
        <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);



Reply via email to