RFR: 8263185: Mallinfo deprecated in glibc 2.33 [v4]

David Holmes dholmes at openjdk.java.net
Wed Mar 17 00:32:11 UTC 2021


On Tue, 16 Mar 2021 10:15:26 GMT, Christoph Göttschkes <cgo at openjdk.org> wrote:

>> Starting with glibc 2.33, mallinfo is deprecated in favor of the new mallinfo2 API. Both APIs work the same way, the only difference is, that mallinfo2 uses size_t instead of int for the fields of the struct, containing the information about malloc. Please see the [glibc release notes](https://sourceware.org/pipermail/libc-alpha/2021-February/122207.html).
>> 
>> Testing with tier1 on a system with glibc 2.33 and on a system with glibc 2.31.
>
> Christoph Göttschkes has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Resolve mallinfo and mallinfo2 in os::init.

Hi Christoph,

There is no need for build-time glibc version checks - see below.

Thanks,
David

src/hotspot/os/linux/os_linux.cpp line 2238:

> 2236:   bool called_mallinfo = false;
> 2237:   bool might_have_wrapped = false;
> 2238: #if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 33)

This is not needed - you are using a build-time value to determine whether to perform a runtime action. The mallinfo2 call should be attempted on all platforms regardless of the build platform characteristic.

src/hotspot/os/linux/os_linux.cpp line 174:

> 172: 
> 173: void* os::Linux::_mallinfo_fun_ptr = NULL;
> 174: void* os::Linux::_mallinfo2_fun_ptr = NULL;

Should this be ifdef __GLIBC__ too?

src/hotspot/os/linux/os_linux.cpp line 4426:

> 4424:   Linux::_mallinfo_fun_ptr = dlsym(RTLD_DEFAULT, "mallinfo");
> 4425:   Linux::_mallinfo2_fun_ptr = dlsym(RTLD_DEFAULT, "mallinfo2");
> 4426: 

Should this be ifdef __GLIBC__ too?

src/hotspot/os/linux/os_linux.hpp line 257:

> 255: 
> 256:   static void* _mallinfo_fun_ptr;
> 257:   static void* _mallinfo2_fun_ptr;

Should this be ifdef __GLIBC__ too?

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

Changes requested by dholmes (Reviewer).

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


More information about the hotspot-runtime-dev mailing list