RFR: JDK-8277029: JMM GetDiagnosticXXXInfo APIs should verify output array sizes

Serguei Spitsyn sspitsyn at openjdk.java.net
Tue Nov 16 01:57:37 UTC 2021


On Mon, 15 Nov 2021 10:18:52 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> src/hotspot/share/services/management.cpp line 1968:
>> 
>>> 1966: 
>>> 1967: JVM_ENTRY(void, jmm_GetDiagnosticCommandInfo(JNIEnv *env, jobjectArray cmds,
>>> 1968:           dcmdInfo* infoArray, jint count))
>> 
>> I do not see the point of the change in this case. This doesn't check for a mismatch between an "external" and "internal" value but between two external values. If you don't trust the caller to size infoArray correctly then how can you trust them to pass in the right "count" ?
>
> Well, it warns in case of programming errors. I agree, that programming error is very unlikely since the caller has all the information he needs. And he could pass in the wrong count. 
> 
> Idk. Mostly I changed this interface to follow the established pattern of always passing in an explicit output buffer size. And to keep it symmetric to``jmm_GetDiagnosticCommandArgumentsInfo` and `jmm_GetGCExtAttributeInfo`. If you object, I'll remove this part.

Hi Thomas,

I kind of agree with David.
The symmetry does not help in this case as it creates a bit of confusion. :)

Thanks,
Serguei

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

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


More information about the serviceability-dev mailing list