Bug 256477

Summary: cannot install java/openjdk11
Product: Ports & Packages Reporter: lumiwa
Component: Individual Port(s)Assignee: freebsd-java (Nobody) <java>
Status: Open ---    
Severity: Affects Only Me CC: emaste, java, jrm, justine.akehurst, lumiwa, maciphone2, michaelo, mikael, pmc
Priority: --- Flags: linimon: maintainer-feedback? (java)
Version: Latest   
Hardware: amd64   
OS: Any   
Attachments:
Description Flags
configure.log of building openjdk1 none

Description lumiwa 2021-06-08 07:40:10 UTC
Created attachment 225632 [details]
configure.log of building openjdk1

My system is FreeBSD 13.0-RELEASE-p1, fresh install. Yesterday was update of LibereOffice and it stopped because problem with Openjdk11.
checking for cacerts file...
/usr/ports/java/openjdk11/files/cacerts checking if packaged modules
are kept... yes (default) checking for version string... 11.0.11+9-1
configure: Found potential Boot JDK using configure arguments
configure: Potential Boot JDK found at /usr/local/bootstrap-openjdk11
is incorrect JDK version (Error occurred during initialization of VM);
ignoring configure: (Your Boot JDK version must be one of: 10 11)
configure: error: The path given by --with-boot-jdk does not contain a
valid Boot JDK configure exiting with result code 1 ===>  Script
"configure" failed unexpectedly. Please report the problem to
java@FreeBSD.org [maintainer] and attach the
"/usr/ports/java/openjdk11/work/openjdk-jdk11u-jdk-11.0.11-9-1/config.log"
including the output of the failure of your make command. Also, it
might be a good idea to provide an overview of all packages installed
on your system (e.g. a /usr/local/sbin/pkg-static info -g -Ea). ***
Error code 1

I tried  to install openjdk8 and 12 but it was the same problem.
Please, check the attached log.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2021-06-08 09:45:13 UTC
^Triage: give more effective Summary; clear stray maintainer-feedback flag.
Comment 2 lumiwa 2021-06-20 16:41:22 UTC
I try to install again and the problem exist.
BTW: Is java mailing list active still, please?
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2021-06-20 19:47:01 UTC
^Triage: sorry, but the maintainer-feedback+ flag is only intended to be set by the maintainer.
Comment 4 Klaus Küchemann 2021-06-20 22:46:37 UTC
(In reply to lumiwa from comment #0)
<<......configure: Potential Boot JDK found at /usr/local/bootstrap-openjdk11
is incorrect JDK version (Error occurred during initialization of VM);
ignoring configure: (Your Boot JDK version must be one of: 10 11).....>>

your bug-report is not reproducible :

----check: ----
root@freebsd:~ # /usr/local/bootstrap-openjdk11/bin/java -version
openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment (build 11.0.5+10-1)
OpenJDK 64-Bit Server VM (build 11.0.5+10-1, mixed mode)

--port-installation :---
....
checking for version string... 11.0.11+9-1
configure: Found potential Boot JDK using configure arguments
checking for Boot JDK... /usr/local/bootstrap-openjdk11
checking Boot JDK version... openjdk version "11.0.5" 2019-10-15 OpenJDK Runtime Environment (build 11.0.5+10-1) OpenJDK 64-Bit Server VM (build 11.0.5+10-1, mixed mode) 
checking for java in Boot JDK... ok
...
-----

wherever your bug comes from you could e.g. simply do :

root@freebsd:~ # rm -rf /usr/local/bootstrap-openjdk11
root@freebsd:/usr/ports/java/bootstrap-openjdk11 # make clean
root@freebsd:/usr/ports/java/bootstrap-openjdk11 # make deinstall reinstall clean

.....

good luck
Comment 5 Klaus Küchemann 2021-06-29 15:09:51 UTC
@ lumiwa@gmail.com :
can you please mark this bugzilla as closed / fixed 
or describe what happens if you apply my hint above?
Comment 6 lumiwa 2021-07-03 09:45:08 UTC
For whatever reaso it doesn't work for me.
I di what you wrote and that try to install openjdk11 and I got:
configure: Found potential Boot JDK using configure arguments
configure: Potential Boot JDK found at /usr/local/bootstrap-openjdk11 is incorrect JDK version (Error occurred during initialization of VM); ignoring
configure: (Your Boot JDK version must be one of: 10 11)
configure: error: The path given by --with-boot-jdk does not contain a valid Boot JDK
configure exiting with result code 1
===>  Script "configure" failed unexpectedly.
Please report the problem to java@FreeBSD.org [maintainer] and attach the
"/usr/ports/java/openjdk11/work/openjdk-jdk11u-jdk-11.0.11-9-1/config.log"
including the output of the failure of your make command. Also, it might be
a good idea to provide an overview of all packages installed on your system
(e.g. a /usr/local/sbin/pkg-static info -g -Ea).
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/java/openjdk11
*** Error code 1

Stop.
make: stopped in /usr/ports/java/openjdk11

I am using gitup for ports.
Comment 7 Klaus Küchemann 2021-07-03 11:17:44 UTC
(In reply to lumiwa from comment #6)
can you please post the output of:

/usr/local/bootstrap-openjdk11/bin/java -version

?
Comment 8 lumiwa 2021-07-04 15:22:03 UTC
 /usr/local/bootstrap-openjdk11/bin/java -version
Error occurred during initialization of VM
Could not reserve enough space in CodeHeap 'non-nmethods' (2496K)
Comment 9 Mikael Urankar freebsd_committer freebsd_triage 2021-07-04 16:21:36 UTC
Are you using the official binary package for the bootstrap?
Comment 10 Klaus Küchemann 2021-07-04 20:45:22 UTC
(In reply to Mikael Urankar from comment #9)

<<Are you using the official binary package for the bootstrap?>>
..

@lumiwa : to be sure you have the correct bootstrap-version in your search path  you can do the following :
-1.
root@freebsd:~ # wget https://pkg.freebsd.org/FreeBSD:13:amd64/latest/All/bootstrap-openjdk11-11.0.5.10.1.txz

.... - 'bootstrap-openjdk11-11.0.5.10.1.txz' saved [103071984/103071984]

-2. 
root@freebsd:~ # xz -d bootstrap-openjdk11-11.0.5.10.1.txz

-3.
root@freebsd:~ # tar xvf bootstrap-openjdk11-11.0.5.10.1.tar

-4.
root@freebsd:~ # mv usr/local/bootstrap-openjdk11/ /usr/local/bootstrap-openjdk11/

-5.
repeat command /usr/local/bootstrap-openjdk11/bin/java -version (and please post it here again) - it should print:

root@freebsd:~ # /usr/local/bootstrap-openjdk11/bin/java -version
openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment (build 11.0.5+10-1)
OpenJDK 64-Bit Server VM (build 11.0.5+10-1, mixed mode)
--
Comment 11 lumiwa 2021-07-05 10:47:53 UTC
I am using ports and for update ports I am using gitup.
Comment 12 Klaus Küchemann 2021-07-05 14:01:07 UTC
(In reply to lumiwa from comment #0)
<<.....I tried  to install openjdk8 and 12 but it was the same problem.....>>

what was the exact same problem for openjdk8 ? ( openjdk8 doesn't use openjdk11`s-bootstrap)


(In reply to lumiwa from comment #11)

<<...I am using ports and for update ports I am using gitup...>>

did you try: 'pkg install openjdk8' & 'pkg install openjdk11' ?

... so 
if 
every installed(or manually placed like in comment #10)
  jdk or jre on your system  prints :
<<Error occurred during initialization of VM
Could not reserve enough space in CodeHeap 'non-nmethods' (2496K)>>
(from your comment #8)
then 
there's something goin`wrong with your system which is hard or impossible to remote-debug 
w/o more information about running pids(or dmesg etc.) and so on.
assuming you have enough RAM , I'm out of "remote-guessing-idea".
of course you could try something like :
' java -Xms256m -Xmx512m -version '
but your bug really shouldn't happen under a correct port-installation on a "healthy  13.0-RELEASE-system" .

.. well, sidenote:  libreoffice has another upgrade since your entry comment #0
Comment 13 lumiwa 2021-07-05 18:07:37 UTC
I think and is it possible to my sysctl.conf settings:
...
kern.elf32.aslr.enable=1
kern.elf32.aslr.honor_sbrk=0
kern.elf32.aslr.pie_enable=1
kern.elf32.allow_wx=0
kern.elf64.aslr.enable=1
kern.elf64.aslr.honor_sbrk=0
kern.elf64.aslr.pie_enable=1
kern.elf64.allow_wx=0
kern.ipc.shm_use_phys=1
...

Thank you.
Comment 14 Klaus Küchemann 2021-07-05 22:45:58 UTC
(In reply to lumiwa from comment #13)
yes, thanks for telling us the root cause of your bug :

root@freebsd:~ # sysctl kern.elf64.allow_wx=0
kern.elf64.allow_wx: 1 -> 0
root@freebsd:~ # /usr/local/bootstrap-openjdk11/bin/java -version
Error occurred during initialization of VM
Could not reserve enough space in CodeHeap 'non-nmethods' (2496K)
--
root@freebsd:~ # sysctl kern.elf64.allow_wx=1
kern.elf64.allow_wx: 0 -> 1
root@freebsd:~ # /usr/local/bootstrap-openjdk11/bin/java -version
openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment (build 11.0.5+10-1)
OpenJDK 64-Bit Server VM (build 11.0.5+10-1, mixed mode)
Comment 15 lumiwa 2021-07-06 07:53:04 UTC
Thank you very much.

The problem is solved.
Comment 16 Ed Maste freebsd_committer freebsd_triage 2023-03-10 18:49:49 UTC
Re-open - we really want to have the wxneeded flag set on the binary as part of the port build. This will have no effect for people with default allow_wx=1, but when allow_wx=0 it will indicate that the binary should opt-out.
Comment 17 Peter Much 2023-03-10 19:45:06 UTC
Ed, thanks for re-opening

Here is a whole directory of binaries ending up in /usr/local/openjdk11/bin, and most, maybe all of them do not like to run without wxneeded. 

Then, the port Makefile defines 

JDK_BUILDDIR=   ${WRKSRC}/build/${JDK_OSARCH}- normal-${JDK_BUILD_JVM}-${JDK_BUILD_TYPE}

After a few futile tries to make things work with that variable, I gave up and just did this:

post-build:
        # USES=elfctl does not work here, because the .for loop there
        # gets expanded before the destination dir of the binaries is known
        ${ELFCTL} -i -e +wxneeded ${JDK_IMAGEDIR}/bin/*
Comment 18 Joseph Mingrone freebsd_committer freebsd_triage 2023-03-12 23:49:20 UTC
If I understand correctly, to fix the build of java/openjdk11 we need to set wxneeded on ${LOCALBASE}/bootstrap-openjdk11/bin/java from java/bootstrap-openjdk11. However, there is a problem.

# elfctl -e +wxneeded /usr/local/bootstrap-openjdk11/bin/java
elfctl: NT_FREEBSD_FEATURE_CTL note not found
Comment 19 Peter Much 2023-03-13 13:00:40 UTC
(In reply to Joseph Mingrone from comment #18)
I can reproduce this:

# tar xvf bootstrap-openjdk11-11.0.5.10.1.pkg
# elfctl -e +wxneeded ./usr/local/bootstrap-openjdk11/bin/java
elfctl: NT_FREEBSD_FEATURE_CTL note not found
elfctl: NT_FREEBSD_FEATURE_CTL note not found

# file ./usr/local/bootstrap-openjdk11/bin/java
usr/local/bootstrap-openjdk11/bin/java: ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 11.3, FreeBSD-style, not stripped
$ file /usr/local/openjdk11/bin/java
/usr/local/openjdk11/bin/java: ELF 64-bit LSB pie executable, x86-64, version 1 (FreeBSD), dynamically linked, interpreter /libexec/ld-elf.so.1, for FreeBSD 13.2, FreeBSD-style, not stripped
Comment 20 Ed Maste freebsd_committer freebsd_triage 2023-03-13 13:35:52 UTC
(In reply to Peter Much from comment #19)
> # file ./usr/local/bootstrap-openjdk11/bin/java
> ... for FreeBSD 11.3 ...

The CSU bits in FreeBSD 11.3 did not have the template ELF note to record feature flags. We'll need a new bootstrap Java built on 12.2 or later, or 13.0 or later.
Comment 21 Justine Akehurst 2023-11-14 04:24:17 UTC
(In reply to Ed Maste from comment #20)

I am also running into this issue. When can we expect to see a resolution here?