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

blooprifle: add -XX:+IgnoreUnrecognizedVMOptions to hardCodedDefaultJavaOpts #1845

Merged

Conversation

Flowdalic
Copy link
Contributor

@Flowdalic Flowdalic commented Feb 9, 2023

This was (is?) an attempt to fix #1843. However, adding this line had no effect. Just like removing the XX:MaxInlineLevel line. I assume that the error in #1843 is caused by a different code path. I suspect https://github.com/scalacenter/bloop/blob/a249e0a710ce169ca05d0606778f96f44a398680/bloopgun/src/main/scala/bloop/bloopgun/util/Environment.scala#L87, where, according to the code comment, the code in scala-cli originates from.

I wonder if it is wise to hard code non-standard JVM options like it is done here and in scalacenter/bloop. As apparently #1843 demonstrates, some (most?) JVM will bail out if they are invoked with options they do not recognize (which is IMHO sensible behavior). I would be great of all TCK compatible JVMs would be supported by scala-cli (and bloop). So either do not use non-standard hard coded options, or add -XX:+IgnoreUnrecognizedVMOptions (which, according to JDK-6788376, is available since Java 6)1.

1: A third option would be to only issue the option if it was detected the receiving JVM supports it. But that is probably not trivial to implement.

@lwronski
Copy link
Contributor

The comment here indicates that this JVM option is ignored by GraalVM, but it isn't.

I found here an interesting flag in the Graal project that may address your issue.

Can you add "-Dgraal.Inline=false" around here and check if it fix your problem?

@Flowdalic
Copy link
Contributor Author

Can you add "-Dgraal.Inline=false" around here and check if it fix your problem?

Note that I see this error with the standalone JVM launcher and not with a native image created by Graal1. So I assume your suggestion does not apply?

1: I execute scala-cli on an armle machine and Graal has no support for 32-bit arm.

@lwronski
Copy link
Contributor

lwronski commented Feb 13, 2023

@Flowdalic Thank you for working on this issue.

I would like to suggest an alternative solution. Would it be possible for you to make the option -XX:+IgnoreUnrecognizedVMOptions configurable through an environment variable instead of hardcoding it in the default JVM options?

@lwronski
Copy link
Contributor

lwronski commented Feb 13, 2023

@Flowdalic Thank you for working on this issue. I would like to suggest an alternative solution. Would it be possible for you to make the option -XX:+IgnoreUnrecognizedVMOptions configurable through an environment variable instead of hardcoding it in the default JVM options?

We discussed this internally and we agree to add -XX:+IgnoreUnrecognizedVMOptions, sorry for the confusion.

It seems the following tests are failing and will need to be adjusted:

scala.cli.integration.BloopTests.invalid bloop options passed via cli cause bloop start failure

I suspect this test can be removed as invalid JVM options should not fail bloop.

BTW. let me know if you'll don't have time to fix this, I can have a look.

@Flowdalic
Copy link
Contributor Author

Thanks. I'll look into the test.

Your suggestion to create an environment variable made me wonder if it wouldn't be sensible to be able to override the default hardcoded JVM options via an environment variable e.g., OVERRIDE_BLOOP_JVM_OPTIONS. This would allow to experiment with different JVM options without having to modify the code.

…avaOpts

Some (most?) JVMs fail to launch if they encounter unrecognized
non-standard options. For example, executing scala-cli on a armle
machine running Debian 11 (Bullseye) with openjdk-17-jre-headless
installed results in

flo@raspi:~$ scala-cli bloop output
Unrecognized VM option 'MaxInlineLevel=20'
Did you mean 'MaxForceInlineLevel=<value>'? Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

flo@raspi:~$ java -version
openjdk version "17.0.6" 2023-01-17
OpenJDK Runtime Environment (build 17.0.6+10-Debian-1deb11u1)
OpenJDK Zero VM (build 17.0.6+10-Debian-1deb11u1, interpreted mode)
@Flowdalic Flowdalic force-pushed the blooprifle-ignore-unrecognized-vm-options branch from fcf0942 to 4964028 Compare February 13, 2023 17:46
@Gedochao
Copy link
Contributor

LGTM, thanks for the contribution!

@Gedochao Gedochao merged commit 120efc0 into VirtusLab:main Feb 14, 2023
@Gedochao Gedochao added the bug Something isn't working label Feb 14, 2023
@Flowdalic Flowdalic deleted the blooprifle-ignore-unrecognized-vm-options branch February 15, 2023 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to start bloop server on armle using Debian 11
3 participants