RFR: JDK-8257604: JNI_ArgumentPusherVaArg leaks valist

Thomas Stuefe stuefe at openjdk.java.net
Wed Dec 2 15:52:01 UTC 2020


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.

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

Commit messages:
 - call va_end on copied argp

Changes: https://git.openjdk.java.net/jdk/pull/1565/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=1565&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8257604
  Stats: 5 lines in 1 file changed: 4 ins; 1 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/1565.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/1565/head:pull/1565

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


More information about the hotspot-dev mailing list