On Fri, 29 Jan 2021 21:33:40 GMT, Alexey Semenyuk <asemen...@openjdk.org> wrote:

> Fix for https://bugs.openjdk.java.net/browse/JDK-8254702
> 
> The fix splits Linux app launcher in app launcher and launcher shared lib. 
> App launcher is pure C and doesn't have C++ code. App launcher lib 
> incorporates bulk of C++ code from app launcher. 
> At startup app launcher loads launcher shared lib and calls functions it 
> provides to get data for launching JVM (path to jli lib and arguments for 
> JLI_Launch function call).
> App launcher unloads launcher shared lib before launching JVM to remove C++ 
> runtime from the process memory.
> 
> Getting rid of C++ code from app launcher required to rewrite app 
> installation location lookup code from C++ to C. LinuxPackage.c source is C 
> alternative for 
> https://github.com/openjdk/jdk/blob/master/src/jdk.jpackage/linux/native/applauncher/Package.cpp
>  and 
> https://github.com/openjdk/jdk/blob/master/src/jdk.jpackage/linux/native/applauncher/Executor.cpp.
> 
> Layout of jpackage's native code changed:
> - `common`: code shared between all jpackage binaries.
> - `applauncher`: launcher only code.
> - `applauncherlib`: launcher lib code on Linux and launcher code on other 
> platforms.
> - `applaunchercommon`: code shared between launcher and launcher lib on Linux 
> and launcher code on other platforms.

make/modules/jdk.jpackage/applauncherlib.ld-version-script line 1:

> 1: {

Linker script is "just in case" to guarantee that only controlled set of 
functions is exported from launcher lib. Current set of g++ OpenJDK command 
line options disables export of functions with external linkage by default. 
However in my local builds this was not the case and the whole C++ runtime 
statically linked in launcher lib got exported. This prevented it from 
unloading from launcher's process memory when it was `dlclose()`-ed. This 
linker script used in linkage of launcher lib will guarantee this will not 
happen.

src/jdk.jpackage/share/native/common/tstrings.cpp line 55:

> 53:         ret = _vsntprintf_s(&*fmtout.begin(), fmtout.size(), _TRUNCATE, 
> format, args);
> 54: #else
> 55: #if defined(__GNUC__) && __GNUC__ >= 5

Local build with older g++compiler bugfix.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2320

Reply via email to