Re: RFR: 8283225: ClassLoader.c produces incorrect OutOfMemory Exception when length is 0 (aix) [v3]

2022-03-17 Thread Tyler Steele
On Thu, 17 Mar 2022 14:48:09 GMT, Roger Riggs  wrote:

>> src/java.base/share/native/libjava/ClassLoader.c line 102:
>> 
>>> 100: }
>>> 101: 
>>> 102: // On malloc(0), implementators of malloc(3) have the choice to 
>>> return either
>> 
>> It is confusing to mix `malloc(0)`, where you are passing an argument zero 
>> to malloc, with `malloc(3)` which actually means the definition of malloc as 
>> per the man page in section 3.
>> 
>> Given this is only an issue on AIX the comment can simply say:
>> 
>> `// On AIX malloc(0) returns NULL which looks like an out-of-memory 
>> condition; so adjust it to malloc(1)`.
>
> I would omit the bug number reference, they get stale and do not age well, 
> cluttering up the source.
> Git blame can be used to find the origin of the comment if needed.

I changed to the streamlined comment and removed the bug id. Thanks for your 
suggestions.

-

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


Re: RFR: 8283225: ClassLoader.c produces incorrect OutOfMemory Exception when length is 0 (aix) [v3]

2022-03-17 Thread Tyler Steele
On Thu, 17 Mar 2022 07:46:21 GMT, Thomas Stuefe  wrote:

>> src/java.base/share/native/libjava/ClassLoader.c line 106:
>> 
>>> 104: // we chose the latter. (see 8283225)
>>> 105: #ifdef _AIX
>>> 106: body = (jbyte *)malloc(length == 0 ? 1 : length);
>> 
>> Using AIX_ONLY this can be simplified:
>> 
>> `body = (jbyte *)malloc(length AIX_ONLY( == 0 ? 1 : length));`
>
>> Using AIX_ONLY this can be simplified:
>> 
>> `body = (jbyte *)malloc(length AIX_ONLY( == 0 ? 1 : length));`
> 
> This is jdk, not hotspot. Do we have AIX_ONLY in the JDK?

As Thomas mentioned, this does not seem to work here.

-

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