Bug 2152432 - java-1.8.0-openjdk: C99 compatibility fix for LinuxNativeDispatcher.c
Summary: java-1.8.0-openjdk: C99 compatibility fix for LinuxNativeDispatcher.c
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: java-1.8.0-openjdk
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Florian Weimer
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: PortingToModernCHelpNeeded
TreeView+ depends on / blocked
 
Reported: 2022-12-11 21:25 UTC by Florian Weimer
Modified: 2023-02-07 11:53 UTC (History)
5 users (show)

Fixed In Version: java-1.8.0-openjdk-1.8.0.362.b09-2.fc38
Clone Of:
Environment:
Last Closed: 2023-02-07 11:53:45 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Florian Weimer 2022-12-11 21:25:30 UTC
Java_sun_nio_fs_LinuxNativeDispatcher_getlinelen in jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c calls the free function, but the source file does not include <stdlib.h>. This leads to a build failure with a C compiler which does not support implicit function declarations by default.

The fix is simple:

diff -up java-1.8.0-openjdk-1.8.0.352.b08-1.fc38.x86_64/openjdk/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c.c99 java-1.8.0-openjdk-1.8.0.352.b08-1.fc38.x86_64/openjdk/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c
--- java-1.8.0-openjdk-1.8.0.352.b08-1.fc38.x86_64/openjdk/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c.c99	2022-12-11 22:23:17.729952935 +0100
+++ java-1.8.0-openjdk-1.8.0.352.b08-1.fc38.x86_64/openjdk/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c	2022-12-11 22:23:44.801668107 +0100
@@ -29,6 +29,7 @@
 #include "jlong.h"
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <dlfcn.h>
 #include <errno.h>

But I can't find the appropriate upstream commit for this. The code has been moved around a bit. The present sources with the getlinelen function no longer has this issue (and later OpenJDK releases were not flagged by the Fedora C99 tester, either).

Comment 1 Andrew John Hughes 2022-12-12 16:11:44 UTC
I can try and dig out the upstream commit and backport it, or failing that just do this as a local 8u bug.

But, in general, we know there may be issues like this with legacy JDKs and don't intend to do significant and potentially risky backport work just to silence compilers. The newer JDKs (java-17-openjdk, java-latest-openjdk) tend to fare better with warnings and newer compilers.

Note that, on the C++ side, HotSpot is explicitly built with -std=gnu++98 to avoid newer features in that codebase.

Comment 2 Florian Weimer 2022-12-12 16:19:35 UTC
I think switching to building with -std=gnu89 is the riskier change here. Adding <stdlib.h> should really be harmless. And maybe then also build with -std=gnu17, so that the language default will not change with further compiler upgrades (we are currently at C17 in GCC 12).

Implicit function declaration were removed from the language in 1999, and we really need to reject them by default for programmer convenience. But to do that, we need to fix Fedora (and some upstreams) first.


Note You need to log in before you can comment on or make changes to this bug.