RFR: 8333871: check sysinfo return values

Jaikiran Pai jpai at openjdk.org
Fri Nov 14 10:55:10 UTC 2025


On Fri, 14 Nov 2025 10:33:07 GMT, Matthias Baesken <mbaesken at openjdk.org> wrote:

> In the review of [JDK-8333522](https://bugs.openjdk.org/browse/JDK-8333522) it has been discussed that we might run into issues because of failing sysinfo.
> However we miss checking the return values at some places, this might need adjustment.

src/java.base/unix/native/libjava/java_props_md.c line 394:

> 392:         if (ret == 0) {
> 393:             sprops.cpu_isalist = strdup(list);
> 394:             list[sizeof(list) - 1] = '\0';

Hello Matthias, is this a typo? The assignment to `list` which is no longer used after the previous line where it is duplicated, seems odd. Furthermore, is this explicit null termination needed? In `man strdup` I don't see any such expectations:

> The strdup() function returns a pointer to a new string which is a duplicate of the string s.  Memory for the new string is obtained with malloc(3), and can be freed with free(3).

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28317#discussion_r2527051473


More information about the core-libs-dev mailing list