RFR: JDK-8257604: JNI_ArgumentPusherVaArg leaks valist

Coleen Phillimore coleenp at openjdk.java.net
Wed Dec 2 16:39:59 UTC 2020


On Wed, 2 Dec 2020 15:02:30 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

> JNI_ArgumentPusherVaArg copies the given argument list pointer (va_copy) but never releases it. A call to va_end is missing.
> 
> AFAICS this coding is old. Interestingly, in jdk8 I find this:
> 
>    0:   inline void set_ap(va_list rap) {
>    0: #ifdef va_copy
>    0:     va_copy(_ap, rap);
>    0: #elif defined (__va_copy)
>    0:     __va_copy(_ap, rap);
>    0: #else
>    0:     _ap = rap;
>    0: #endif
>    0:   }
> 
> `_ap = rap` seems a strangely relaxed way of doing this. But I do not know the history behind that.
> 
> I could not find any usage of the original arg pointer, so maybe the `va_copy()` is not even needed. The jdk8 coding seems to indicate that too. But since I was not 100% sure I kept the `va_copy()` and added a `va_end()`.
> 
> I also made this private (removed the `protected`) since there are no child classes.

Looks good.

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

Marked as reviewed by coleenp (Reviewer).

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


More information about the hotspot-dev mailing list