[jdk19] RFR: 8289148: j.l.foreign.VaList::nextVarg call could throw IndexOutOfBoundsException or even crash the VM

Jorn Vernee jvernee at openjdk.org
Tue Jul 5 15:18:45 UTC 2022


On Tue, 5 Jul 2022 11:13:15 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> This patch changes all VaList implementations to throw `NoSuchElementException` when out of bounds reads occur on a VaList that is created using the Java builder API. The docs are updated accordingly.
>> 
>> For VaLists that are created from native addresses, we don't know their bounds, so we can not throw exceptions in that case.
>> 
>> Testing: `jdk_foreign` test suite on all platforms that implement VaList.
>
> src/java.base/share/classes/java/lang/foreign/VaList.java line 99:
> 
>> 97:      * @throws WrongThreadException if this method is called from a thread other than the thread owning
>> 98:      * the {@linkplain #session() session} associated with this variable argument list.
>> 99:      * @throws NoSuchElementException if an out-of-bounds read is detected.
> 
> I'd insert a link to the safety section, where the link text is "out-of-bounds".

Good idea, I'll add links

> src/java.base/share/classes/jdk/internal/foreign/abi/x64/sysv/SysVVaList.java line 291:
> 
>> 289:     }
>> 290: 
>> 291:     private void checkRegAreaElement(MemoryLayout layout, TypeClass typeClass) {
> 
> should this be `checkRegSaveAreaElement` ?

Okay, I can rename it.

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

PR: https://git.openjdk.org/jdk19/pull/91


More information about the core-libs-dev mailing list