Bug 267690 - java/openjdk*: build fails silently (and hard in poudriere-devel) due to bad usage of printf in bash
Summary: java/openjdk*: build fails silently (and hard in poudriere-devel) due to bad ...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-java (Nobody)
URL: https://bugs.openjdk.org/browse/JDK-8...
Keywords:
Depends on:
Blocks:
 
Reported: 2022-11-10 12:54 UTC by Michael Osipov
Modified: 2023-04-17 08:14 UTC (History)
4 users (show)

See Also:
bugzilla: maintainer-feedback? (java)


Attachments
Patch 1 (OpenJDK 8) (482 bytes, patch)
2022-11-10 12:54 UTC, Michael Osipov
no flags Details | Diff
Patch 2 (OpenJDK 8) (494 bytes, patch)
2022-11-10 12:55 UTC, Michael Osipov
no flags Details | Diff
Git-formatted patch (2.31 KB, patch)
2022-11-10 18:56 UTC, Michael Osipov
no flags Details | Diff
Git-formatted patch (2.75 KB, patch)
2023-02-25 14:58 UTC, Michael Osipov
no flags Details | Diff
Git-formatted patch (java/openjdk8) (2.75 KB, patch)
2023-04-14 12:58 UTC, Michael Osipov
no flags Details | Diff
Git-formatted patch (java/openjdk11) (1.25 KB, patch)
2023-04-14 12:59 UTC, Michael Osipov
no flags Details | Diff
Git-formatted patch (java/openjdk17) (1.25 KB, patch)
2023-04-14 12:59 UTC, Michael Osipov
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Osipov 2022-11-10 12:54:17 UTC
This was found during: https://github.com/freebsd/poudriere/issues/883

When trying to build java/openjdk8 with poudriere-devel I get the following failure:
===============
A new configuration has been successfully created in
/wrkdirs/usr/ports/java/openjdk8/work/jdk8u-jdk8u342-b07.1/build/bsd-x86_64-normal-server-release
using configure arguments '--with-boot-jdk=/usr/local/bootstrap-openjdk8 --with-build-number=b07 --with-update-version=342 --with-vendor-name='OpenJDK BSD Porting Team' --with-vendor-url=https://github.com/battleblow/jdk8u/ --with-vendor-bug-url=mumu --with-vendor-vm-bug-url=mumu --disable-freetype-bundling --disable-zip-debug-info --with-cacerts-file=/usr/ports/java/openjdk8/files/cacerts --with-cups=/usr/local --with-debug-level=release --with-freetype=/usr/local --with-freetype-include=/usr/local/include/freetype2 --with-jobs=20 --with-jvm-variants=server --with-milestone=fcs --with-package-path=/usr/local --with-zlib=system --enable-unlimited-crypto --disable-debug-symbols --with-giflib=system --x-includes=/usr/local/include --x-libraries=/usr/local/lib --x-libraries=/usr/local/lib --x-includes=/usr/local/include --prefix=/usr/local --localstatedir=/var --mandir=/usr/local/man --infodir=/usr/local/share/info/ --build=amd64-portbld-freebsd12.3'.

Configuration summary:
* Debug level:    release
* JDK variant:    normal
* JVM variants:   server
* OpenJDK target: OS: bsd, CPU architecture: x86, address length: 64

Tools summary:
* Boot JDK:       openjdk version "1.8.0_144" OpenJDK Runtime Environment (build 1.8.0_144-b01) OpenJDK 64-Bit Server VM (build 25.144-b01, mixed mode)  (at /usr/local/bootstrap-openjdk8)
* Toolchain:      clang (clang/LLVM)
* C Compiler:     Version 10.0.1 (at /usr/bin/cc)
* C++ Compiler:   Version 10.0.1 (at /usr/bin/c++)

Build performance summary:
* Cores to use:   20
* Memory limit:   32601 MB

===========================================================================
=======================<phase: build          >============================
===== env: NO_DEPENDS=yes USER=nobody UID=65534 GID=65534
===>  Building for openjdk8-8.342.07.1_1
gmake[1]: Entering directory '/wrkdirs/usr/ports/java/openjdk8/work/jdk8u-jdk8u342-b07.1'
(cd /wrkdirs/usr/ports/java/openjdk8/work/jdk8u-jdk8u342-b07.1/make && /usr/local/bin/gmake 3 VERBOSE="3" LOG_LEVEL="warn" -R -I /wrkdirs/usr/ports/java/openjdk8/work/jdk8u-jdk8u342-b07.1/make/common "SPEC=/wrkdirs/usr/ports/java/openjdk8/work/jdk8u-jdk8u342-b07.1/build/bsd-x86_64-normal-server-release/spec.gmk" -j20 -f SourceRevision.gmk create-source-revision-tracker)
gmake[2]: Entering directory '/wrkdirs/usr/ports/java/openjdk8/work/jdk8u-jdk8u342-b07.1/make'
gmake[2]: *** No rule to make target '3'.  Stop.
gmake[2]: Leaving directory '/wrkdirs/usr/ports/java/openjdk8/work/jdk8u-jdk8u342-b07.1/make'
gmake[1]: *** [/wrkdirs/usr/ports/java/openjdk8/work/jdk8u-jdk8u342-b07.1//make/Main.gmk:207: create-source-revision-tracker] Error 2
gmake[1]: Leaving directory '/wrkdirs/usr/ports/java/openjdk8/work/jdk8u-jdk8u342-b07.1'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

Stop.
make: stopped in /usr/ports/java/openjdk8
=>> Cleaning up wrkdir
===>  Cleaning for openjdk8-8.342.07.1_1
build of java/openjdk8 | openjdk8-8.342.07.1_1 ended at Wed Nov  9 23:47:04 CET 2022
build time: 00:00:38
!!! build failure encountered !!!
===============

This failure cannot be reproduced when you are INSIDE of the poudriere jail or running on any other host. This silently fails for 8, 11, 17, 18:
====================================================
A new configuration has been successfully created in
/usr/ports/java/openjdk11/work/jdk11u-jdk-11.0.16-8-1/build/bsd-x86_64-normal-server-release
using configure arguments '--with-boot-jdk=/usr/local/bootstrap-openjdk11 --disable-ccache --disable-javac-server --disable-hotspot-gtest --with-jvm-features=shenandoahgc --with-alsa=/usr/local --with-cups=/usr/local --with-fontconfig=/usr/local --with-freetype=system --with-freetype-include=/usr/local/include/freetype2 --with-freetype-lib=/usr/local/lib --with-libjpeg=system --with-giflib=system --with-giflib-include=/usr/local/include --with-giflib-lib=/usr/local/lib --with-libpng=system --with-zlib=system --with-lcms=system --x-includes=/usr/local/include --x-libraries=/usr/local/lib --with-cacerts-file=/usr/ports/java/openjdk11/files/cacerts --with-version-string=11.0.16+8-1 --with-native-debug-symbols=none --with-debug-level=release --with-vendor-name='OpenJDK BSD Porting Team' --with-vendor-url=https://github.com/battleblow/jdk11u/ --with-vendor-bug-url='https://bugs.freebsd.org/bugzilla/enter_bug.cgi?product=Ports/usr/ports/java/openjdk11/work/jdk11u-jdk-11.0.16-8-1/build/.configure-support/generated-configure.sh: line 73037: printf: `%': invalid format character
==================================================
A new configuration has been successfully created in
/usr/ports/java/openjdk17/work/jdk17u-jdk-17.0.4-8-1/build/bsd-x86_64-server-release
using configure arguments '--with-boot-jdk=/usr/local/bootstrap-openjdk17 --disable-ccache --disable-javac-server --disable-hotspot-gtest --with-alsa=/usr/local --with-cups=/usr/local --with-fontconfig=/usr/local --with-freetype=system --with-freetype-include=/usr/local/include/freetype2 --with-freetype-lib=/usr/local/lib --with-libjpeg=system --with-giflib=system --with-giflib-include=/usr/local/include --with-giflib-lib=/usr/local/lib --with-harfbuzz=system --with-libpng=system --with-zlib=system --with-lcms=system --x-includes=/usr/local/include --x-libraries=/usr/local/lib --with-cacerts-file=/usr/ports/java/openjdk17/files/cacerts --with-version-string=17.0.4+8-1 --with-native-debug-symbols=none --with-debug-level=release --with-vendor-name='OpenJDK BSD Porting Team' --with-vendor-url=https://github.com/battleblow/jdk17u/ --with-vendor-bug-url='https://bugs.freebsd.org/bugzilla/enter_bug.cgi?product=Ports/usr/ports/java/openjdk17/work/jdk17u-jdk-17.0.4-8-1/build/.configure-support/generated-configure.sh: line 140713: printf: `%': invalid format character
==================================================
but build continues

Failure is:
> /build/.configure-support/generated-configure.sh: line 140713: printf: `%': invalid format character

These failures are caused by incorrect usage of printf. Instead of doing 'printf "%s\n" "$URL"' they do 'printf "$URL\n"'.

Affected files:
8:
common/autoconf/generated-configure.sh
common/autoconf/help.m4
11,17:
./make/autoconf/help.m4
./build/.configure-support/generated-configure.sh

Attached are two patches made with "make makepatch" for OpenJDK 8.

Build then works on host, in jail and with poudriere bulk/testport. Then ran a simple program in the poudiere jail and all system properties are fine.
Comment 1 Michael Osipov 2022-11-10 12:54:55 UTC
Created attachment 237999 [details]
Patch 1 (OpenJDK 8)
Comment 2 Michael Osipov 2022-11-10 12:55:13 UTC
Created attachment 238000 [details]
Patch 2 (OpenJDK 8)
Comment 3 Michael Osipov 2022-11-10 12:56:59 UTC
I don't understand why it fails hard in poudriere, but silently else. The value in the URL has been introduced times ago by me and for this reason I did not notice it.
Comment 4 Michael Osipov 2022-11-10 18:56:57 UTC
Created attachment 238004 [details]
Git-formatted patch

Here is a Git-formatted patch, tested in poudriere. can provide for 11+ as well.
Comment 5 Michael Osipov 2023-01-27 08:13:45 UTC
This is not also logged upstream.
Comment 6 Michael Osipov 2023-01-28 22:49:07 UTC
now*
Comment 7 void 2023-02-24 23:04:52 UTC
(In reply to Michael Osipov from comment #4)

Hi,

This patch doesn't fix the problem at present (2023-02-24)
Comment 8 void 2023-02-24 23:33:59 UTC
(In reply to void from comment #7)

(not sure if it's the same problem) but the patch applies :)

# patch -p1 < openjdk8-git.patch
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|commit 510593c26c8c49c1e2553917663d468517a08e08
|Author: Michael Osipov <michael.osipov@siemens.com>
|Date:   2022-11-10T19:53:36+01:00
|
|    java/openjdk8: fix invalid use of printf which might lead to build failures
|    
|    Our JDK_BUG_URL contains percent characters which are passed as format string to
|    printf. These printf statements fail. Instead, we pass now this value as arg.
|
|diff --git a/java/openjdk8/Makefile b/java/openjdk8/Makefile
|index 348f62a25e46..a46067cdc960 100644
|--- a/java/openjdk8/Makefile
|+++ b/java/openjdk8/Makefile
--------------------------
Patching file java/openjdk8/Makefile using Plan A...
Hunk #1 succeeded at 1.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/java/openjdk8/files/patch-common_autoconf_generated-configure.sh b/java/openjdk8/files/patch-common_autoconf_generated-c
onfigure.sh
|new file mode 100644
|index 000000000000..ff1b620587c5
|--- /dev/null
|+++ b/java/openjdk8/files/patch-common_autoconf_generated-configure.sh
--------------------------
(Creating file java/openjdk8/files/patch-common_autoconf_generated-configure.sh...)
Patching file java/openjdk8/files/patch-common_autoconf_generated-configure.sh using Plan A...
Empty context always matches.
Hunk #1 succeeded at 1.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/java/openjdk8/files/patch-common_autoconf_help.m4 b/java/openjdk8/files/patch-common_autoconf_help.m4
|new file mode 100644
|index 000000000000..91803c086052
|--- /dev/null
|+++ b/java/openjdk8/files/patch-common_autoconf_help.m4
--------------------------
(Creating file java/openjdk8/files/patch-common_autoconf_help.m4...)
Patching file java/openjdk8/files/patch-common_autoconf_help.m4 using Plan A...
Empty context always matches.
Hunk #1 succeeded at 1.
done

build fails like so:

[00:00:30] checking for unzip... unzip
[00:00:30] checking for wget... no
[00:00:30] checking for lftp... no
[00:00:30] checking for ftp... ftp
[00:00:30] checking headful support... include support for both headful and headless
[00:00:30] checking whether to build JFR... true
[00:00:30] configure: Found potential Boot JDK using configure arguments
[00:00:30] configure: Potential Boot JDK found at /usr/local/bootstrap-openjdk8 is incorrect JDK version (Error occurred during initialization of VM); ignoring
[00:00:30] configure: (Your Boot JDK must be version 7 or 8)
[00:00:30] configure: error: The path given by --with-boot-jdk does not contain a valid Boot JDK
[00:00:30] ===========================================================================
[00:00:30] =======================<phase: build          >============================
[00:00:30] ===== env: NO_DEPENDS=yes USER=root UID=0 GID=0
[00:00:30] ===>  Building for openjdk8-8.362.09.1_2
[00:00:30] gmake[1]: Entering directory '/wrkdirs/usr/ports/java/openjdk8/work/jdk8u-jdk8u362-b09.1'
[00:00:30] No configurations found for /wrkdirs/usr/ports/java/openjdk8/work/jdk8u-jdk8u362-b09.1/! Please run configure to create a configuration.
[00:00:30] Makefile:55: *** Cannot continue.  Stop.
[00:00:30] gmake[1]: Leaving directory '/wrkdirs/usr/ports/java/openjdk8/work/jdk8u-jdk8u362-b09.1'
[00:00:30] ===> Compilation failed unexpectedly.
[00:00:30] Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
[00:00:30] the maintainer.
[00:00:30] *** Error code 1
[00:00:30] 
[00:00:30] Stop.
[00:00:30] make: stopped in /usr/ports/java/openjdk8
[00:00:30] =>> Cleaning up wrkdir
Comment 9 Michael Osipov 2023-02-25 14:09:17 UTC
(In reply to void from comment #8)

That is weird. This is totally unrelated to the boot JDK, but I will check against latest master today.
Comment 10 Michael Osipov 2023-02-25 14:57:40 UTC
Just tried:
# git log --oneline
1a0e25e83618 (HEAD -> main-custom) www/py-requests: Handle space-separated values in NO_PROXY
5508e84f29f5 java/openjdk8: fix invalid use of printf which might lead to build failures
6e6526510334 print/ghostscript9-agpl-base: remove faulty font mapping for CJK
1c44991d018b (origin/main, origin/HEAD, main) security/clamav-lts: Remove special casing for GCC

# poudriere testport -j 124-release-amd64 -p default-head -i java/openjdk8
...
# git log --oneline
1a0e25e83618 (HEAD -> main-custom) www/py-requests: Handle space-separated values in NO_PROXY
5508e84f29f5 java/openjdk8: fix invalid use of printf which might lead to build failures
6e6526510334 print/ghostscript9-agpl-base: remove faulty font mapping for CJK
1c44991d018b (origin/main, origin/HEAD, main) security/clamav-lts: Remove special casing for GCC
...
hecking headful support... include support for both headful and headless
checking whether to build JFR... true
configure: Found potential Boot JDK using configure arguments
checking for Boot JDK... /usr/local/bootstrap-openjdk8
checking Boot JDK version... openjdk version "1.8.0_144" OpenJDK Runtime Environment (build 1.8.0_144-b01) OpenJDK 64-Bit Server VM (build 25.144-b01, mixed mode) 
checking for java in Boot JDK... ok
checking for javac in Boot JDK... ok
checking for javah in Boot JDK... ok
checking for javap in Boot JDK... ok
checking for jar in Boot JDK... ok
checking for rmic in Boot JDK... ok
checking for native2ascii in Boot JDK... ok
checking if Boot JDK is 32 or 64 bits... 64
checking flags for boot jdk java command ...  
...
=======================<phase: deinstall      >============================
===== env: DEVELOPER_MODE=yes STRICT_DEPENDS=yes USER=root UID=0 GID=0
===>  Deinstalling for openjdk8
===>   Deinstalling openjdk8-8.362.09.1_1
Updating database digests format: .......... done
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

Installed packages to be REMOVED:
	openjdk8: 8.362.09.1_1

Number of packages to be removed: 1

The operation will free 193 MiB.
[124-release-amd64-default-head] [1/1] Deinstalling openjdk8-8.362.09.1_1...
[124-release-amd64-default-head] [1/1] Deleting files for openjdk8-8.362.09.1_1: .......... done
===========================================================================
=>> Checking for extra files and directories
...
Comment 11 Michael Osipov 2023-02-25 14:58:41 UTC
Created attachment 240407 [details]
Git-formatted patch

Rebased the patch, please try again and clean up your poudriere workdir or use a clean set.
Comment 12 void 2023-02-25 15:46:51 UTC
(In reply to Michael Osipov from comment #11)

Thanks, will try shortly and report back
Comment 13 void 2023-02-26 00:01:55 UTC
(In reply to Michael Osipov from comment #11)

This is so weird.

On the system I initially reported the problem on, I made another brand new poudriere jail again, made a completely fresh ports tree with poudriere ports -c, cleaned out /usr/ports/distfiles (deleted and remade the dir) and the problem remains. There is no src.conf or make.conf for either the host, generally for poudriere itself, or for this particular poudriere jail.

On a different machine, did *exactly the same thing*, and the problem isn't there (also it built without your patch).

The main differences - the machine where it doesn't work is an intel i7, baremetal.

The one that *does* work is a Xeon E5-2690, the poudriere runs in a bhyve instance (both server and instance are 13-stable).

I'm going to spin up a bhyve instance on the i7 and install poudriere and see where that goes.
Comment 14 void 2023-02-26 14:12:03 UTC
(In reply to Michael Osipov from comment #11)

It seems it's my system(tm). I made a bhyve instance on the affected system, installed poudriere to it just like the affected system, and it compiles correctly (well, it didn't compile as such, it fetched all what was needed without having to compile openjdk8/11/17 itself)

sorry for the noise
Comment 15 Michael Osipov 2023-03-28 13:35:59 UTC
Port maintainer, can you review?
Comment 16 Kurt Jaeger freebsd_committer freebsd_triage 2023-03-28 15:06:42 UTC
(In reply to Michael Osipov from comment #15)
I'm not the maintainer, but I can reproduce it with poudriere-devel.

I'll ask around.
Comment 17 Michael Osipov 2023-03-28 15:07:20 UTC
(In reply to Kurt Jaeger from comment #16)

Thank you, really appreciated. Maintainer isn't responding, unfortunately.
Comment 18 Michael Osipov 2023-04-14 12:58:52 UTC
Created attachment 241480 [details]
Git-formatted patch (java/openjdk8)
Comment 19 Michael Osipov 2023-04-14 12:59:08 UTC
Created attachment 241481 [details]
Git-formatted patch (java/openjdk11)
Comment 20 Michael Osipov 2023-04-14 12:59:44 UTC
Created attachment 241482 [details]
Git-formatted patch (java/openjdk17)

I have now attached three patches which address the issue in poudriere-devel.
Comment 21 commit-hook freebsd_committer freebsd_triage 2023-04-16 22:49:40 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=f1d77a965b29a10bc80003223bbed8539e35146d

commit f1d77a965b29a10bc80003223bbed8539e35146d
Author:     Greg Lewis <glewis@FreeBSD.org>
AuthorDate: 2023-04-16 22:48:03 +0000
Commit:     Greg Lewis <glewis@FreeBSD.org>
CommitDate: 2023-04-16 22:48:44 +0000

    java/openjdk17: Fix use of printf (causes build failures for poudriere)

    PR:             267690
    Obtained from:  Michael Osipov <michael.osipov@siemens.com>

 java/openjdk17/files/patch-make_autoconf_help.m4 (new) | 11 +++++++++++
 1 file changed, 11 insertions(+)
Comment 22 commit-hook freebsd_committer freebsd_triage 2023-04-16 22:49:42 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=4e9379877c237409818fb4daef36be73b68beb67

commit 4e9379877c237409818fb4daef36be73b68beb67
Author:     Greg Lewis <glewis@FreeBSD.org>
AuthorDate: 2023-04-16 22:47:30 +0000
Commit:     Greg Lewis <glewis@FreeBSD.org>
CommitDate: 2023-04-16 22:48:44 +0000

    java/openjdk11: Fix use of printf (causes build failures for poudriere)

    PR:             267690
    Obtained from:  Michael Osipov <michael.osipov@siemens.com>

 java/openjdk11/files/patch-make_autoconf_help.m4 (new) | 11 +++++++++++
 1 file changed, 11 insertions(+)
Comment 23 commit-hook freebsd_committer freebsd_triage 2023-04-16 22:49:44 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=03c1303690281d3051514c43179ebd9d2624b013

commit 03c1303690281d3051514c43179ebd9d2624b013
Author:     Greg Lewis <glewis@FreeBSD.org>
AuthorDate: 2023-04-16 22:46:40 +0000
Commit:     Greg Lewis <glewis@FreeBSD.org>
CommitDate: 2023-04-16 22:48:44 +0000

    java/openjdk8: Fix use of printf (causes build failures for poudriere)

    PR:             267690
    Obtained from:  Michael Osipov <michael.osipov@siemens.com>

 .../files/patch-common_autoconf_generated-configure.sh (new)  | 11 +++++++++++
 java/openjdk8/files/patch-common_autoconf_help.m4 (new)       | 11 +++++++++++
 2 files changed, 22 insertions(+)
Comment 24 Greg Lewis freebsd_committer freebsd_triage 2023-04-16 22:51:09 UTC
Thanks, I've committed the patches
Comment 25 Michael Osipov 2023-04-17 06:49:02 UTC
(In reply to Greg Lewis from comment #24)

Thank you, Greg. Can they be MFH'd? I it still 2,5 months until next quarterly branch.
Comment 26 Michael Osipov 2023-04-17 08:14:13 UTC
FTR: 18+ are also affected, but I have only addressed LTS releases for now.