Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8173339: AArch64: Fix minimum stack size computations #66

Closed
wants to merge 2 commits into from

Conversation

dongbohe
Copy link
Member

@dongbohe dongbohe commented May 30, 2022

Hi,

I would like to backport this patch to fix minimum stack size computations on AArch64.
I updated the value directly on define_pd_global because JDK-8078556 is not in 8u.

Testing: Performed full jtreg test aarch64-linux-gnu platforms with 4k page size.
Following test case worked correctly after patch.
Before patch:
$ java TLSStackOverflow
[1] 35476 segmentation fault (core dumped) java TLSStackOverflow
After patch:
$ java TLSStackOverflow
got expected stackoverflow, passed

$ keytool -genkey -keyalg RSA -keystore localhost-rsa.jks -storepass changeit -storetype pkcs12
$ cat TLSStackOverflow.java

import javax.net.ServerSocketFactory;
import javax.net.SocketFactory;
import javax.net.ssl.*;
import java.io.*;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

public class TLSStackOverflow
{

    private static final String keystore = "/home/hedongbo/myprojects/study/stackoverflow/new/localhost-rsa.jks";
    private static final char[] passphrase = "changeit".toCharArray();
    private static final int port = 8447;

    private static KeyStore pfx = null;

    public static void doWrite(OutputStream out) throws Exception {
        out.write("hello".getBytes(), 0, 3);
        out.flush();
        doWrite(out);
    }

    public TLSStackOverflow()
    {}

    public static void main(String[] args) throws Exception
    {
        new Thread(() -> {
            try {
                pfx = KeyStore.getInstance("PKCS12");
                pfx.load(new FileInputStream(keystore), passphrase);
                SSLContext ctx = SSLContext.getInstance("TLS");
                KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
                kmf.init(pfx, passphrase);
                KeyManager[] kms = kmf.getKeyManagers();
                ctx.init(kms, null, null);
                ServerSocketFactory fact = ctx.getServerSocketFactory();
                SSLServerSocket serversocket = (SSLServerSocket) fact.createServerSocket(port);
                while (true)
                {
                    Socket socket = null;
                    try
                    {
                        socket = serversocket.accept();

                        DataInputStream in = new DataInputStream(socket.getInputStream());
                        DataOutputStream out = new DataOutputStream(socket.getOutputStream());

                        byte[] buf = new byte[8192];
                        int len = in.read(buf);
                    }
                    catch (Exception e)
                    {
                        e.printStackTrace();
                    }
                    finally
                    {
//                        try
//                        {
//                            socket.close();
//                        }
//                        catch (Exception e) {
//                            e.printStackTrace();
//                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }).start();

        Thread.sleep(2000);

        new Thread(() -> {
            SSLSocket socket = null;
            try {
                pfx = KeyStore.getInstance("PKCS12");
                pfx.load(new FileInputStream(keystore), passphrase);
                SSLContext ctx = SSLContext.getInstance("TLS");
                KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
                kmf.init(pfx, passphrase);
                TrustAllManager[] trust = { new TrustAllManager() };
                ctx.init(null, trust, null);
                SocketFactory fact = ctx.getSocketFactory();
                socket = (SSLSocket) fact.createSocket();
                socket.connect(new InetSocketAddress(InetAddress.getLoopbackAddress(), port), 2000);
                socket.setTcpNoDelay(true);
                socket.startHandshake();

                DataInputStream in = new DataInputStream(socket.getInputStream());
                DataOutputStream out = new DataOutputStream(socket.getOutputStream());

                String s = "GET " + " HTTP/1.1\r\n";
                s+= "Accept: */*\r\n";
                s+= "User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)\r\n";
                s+= "Connection: Close\r\n";
                s+= "\r\n";
                try {
                    doWrite(out);
                } catch (StackOverflowError e) {
                    System.out.println("got expected stackoverflow, passed");
                    System.exit(0);
                }

                byte[] buf = new byte[8192];
                int len = in.read(buf);
                if (len == -1)
                {
                    System.out.println("eof");
                    return;
                }
                System.out.println(new String(buf, 0, len));
            }
            catch (Exception e)
            {
                e.printStackTrace();
            }
            finally
            {
                try
                {
                    socket.close();
                }
                catch (Exception e)
                {}
            }

        }).start();

    }

}


class TrustAllManager implements X509TrustManager
{
    private X509Certificate[] issuers;

    public TrustAllManager()
    {
        this.issuers = new X509Certificate[0];
    }

    public X509Certificate[] getAcceptedIssuers()
    {
        return issuers ;
    }

    public void checkClientTrusted(X509Certificate[] chain, String authType)
    {}

    public void checkServerTrusted(X509Certificate[] chain, String authType)
    {}
}

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8173339: AArch64: Fix minimum stack size computations

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk8u-dev pull/66/head:pull/66
$ git checkout pull/66

Update a local copy of the PR:
$ git checkout pull/66
$ git pull https://git.openjdk.org/jdk8u-dev pull/66/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 66

View PR using the GUI difftool:
$ git pr show -t 66

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk8u-dev/pull/66.diff

Sorry, something went wrong.

@bridgekeeper
Copy link

bridgekeeper bot commented May 30, 2022

👋 Welcome back dongbohe! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot changed the title Backport 540ec375c30e973ceb1a944d5cc60cc8532e88ec 8173339: AArch64: Fix minimum stack size computations May 30, 2022
@openjdk
Copy link

openjdk bot commented May 30, 2022

This backport pull request has now been updated with issue from the original commit.

@openjdk openjdk bot added backport rfr Pull request is ready for review labels May 30, 2022
@mlbridge
Copy link

mlbridge bot commented May 30, 2022

Webrevs

Copy link
Contributor

@theRealAph theRealAph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine. I was a bit freaked out because I'd forgotten that this is a count of "theoretical" 4k pages, regardless of the actual page size, which is 64k on some AArch64 systems.

@openjdk
Copy link

openjdk bot commented May 30, 2022

@dongbohe This change now passes all automated pre-integration checks.

After integration, the commit message for the final commit will be:

8173339: AArch64: Fix minimum stack size computations

Reviewed-by: aph

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 42 new commits pushed to the master branch:

  • 2223058: 8049228: Improve multithreaded scalability of InetAddress cache
  • d0ad242: 8285497: Add system property for Java SE specification maintenance version
  • e3251a2: 8232950: SUNPKCS11 Provider incorrectly check key length for PSS Signatures.
  • 41c7d2d: 8039955: [TESTBUG] jdk/lambda/LambdaTranslationTest1 - java.lang.AssertionError: expected [d:1234.000000] but found [d:1234,000000]
  • a4d4973: 8254318: Remove .hgtags
  • 8ad9018: 8285400: Add '@APinote' to the APIs defined in Java SE 8 MR 3
  • 3a5b2cd: 8201793: (ref) Reference object should not support cloning
  • 1b52b01: 8183107: PKCS11 regression regarding checkKeySize
  • e633df1: 8175797: (ref) Reference::enqueue method should clear the reference object before enqueuing
  • 5323ef6: 8254178: Remove .hgignore
  • ... and 32 more: https://git.openjdk.org/jdk8u-dev/compare/1b4f32d61e3b0460c82598f24dbd5c4dd0fc3bbe...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@theRealAph) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 30, 2022
@dongbohe
Copy link
Member Author

Thank you for your review, Andrew. Tagged the JBS issue with jdk8u-fix-request.

@dongbohe
Copy link
Member Author

dongbohe commented Jun 1, 2022

I found that some test cases fail on OS with 64k page size, and launched a PR #71 to fix these test cases.

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 29, 2022

@dongbohe This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 28, 2022

@dongbohe This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

@bridgekeeper bridgekeeper bot closed this Jul 28, 2022
@gnu-andrew
Copy link
Member

/open

@openjdk
Copy link

openjdk bot commented Aug 26, 2022

@gnu-andrew Only the pull request author can set the pull request state to "open"

@dongbohe
Copy link
Member Author

/open

@openjdk openjdk bot reopened this Aug 26, 2022
@openjdk
Copy link

openjdk bot commented Aug 26, 2022

@dongbohe This pull request is now open

@gnu-andrew
Copy link
Member

I've approved this based on Andrew's review. Please reopen and integrate. Thanks.

@dongbohe
Copy link
Member Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Aug 26, 2022
@openjdk
Copy link

openjdk bot commented Aug 26, 2022

@dongbohe
Your change (at version 881b06f) is now ready to be sponsored by a Committer.

@gnu-andrew
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Aug 26, 2022

Going to push as commit de32daa.
Since your change was applied there have been 42 commits pushed to the master branch:

  • 2223058: 8049228: Improve multithreaded scalability of InetAddress cache
  • d0ad242: 8285497: Add system property for Java SE specification maintenance version
  • e3251a2: 8232950: SUNPKCS11 Provider incorrectly check key length for PSS Signatures.
  • 41c7d2d: 8039955: [TESTBUG] jdk/lambda/LambdaTranslationTest1 - java.lang.AssertionError: expected [d:1234.000000] but found [d:1234,000000]
  • a4d4973: 8254318: Remove .hgtags
  • 8ad9018: 8285400: Add '@APinote' to the APIs defined in Java SE 8 MR 3
  • 3a5b2cd: 8201793: (ref) Reference object should not support cloning
  • 1b52b01: 8183107: PKCS11 regression regarding checkKeySize
  • e633df1: 8175797: (ref) Reference::enqueue method should clear the reference object before enqueuing
  • 5323ef6: 8254178: Remove .hgignore
  • ... and 32 more: https://git.openjdk.org/jdk8u-dev/compare/1b4f32d61e3b0460c82598f24dbd5c4dd0fc3bbe...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Aug 26, 2022
@openjdk openjdk bot closed this Aug 26, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Aug 26, 2022
@openjdk
Copy link

openjdk bot commented Aug 26, 2022

@gnu-andrew @dongbohe Pushed as commit de32daa.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@gnu-andrew
Copy link
Member

Thanks for the quick turn-around!

@dongbohe
Copy link
Member Author

I should do it, thanks for the sponsor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

None yet

3 participants