RFR: 8263434: Dangling references after MethodComparator::methods_EMCP

Coleen Phillimore coleenp at openjdk.java.net
Thu Mar 11 13:38:07 UTC 2021


On Thu, 11 Mar 2021 11:02:43 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> SonarCloud reports the following problem in MethodComparator::methods_EMCP:
>  "Address of stack memory associated with local variable 's_new' is still referred to by the global variable '_s_new' upon returning to the caller. This will be a dangling reference"
> 
> Code inspection reveals the assignment to static variables is only needed to pass them to helper methods. So, while this is not a detectable bug (yet), it is still cleaner not to expose stack variables in globals.
> 
> Additional testing:
>  - [x] Linux x86_64 fastdebug `tier1`
>  - [x] Linux x86_64 fastdebug, `vmTestbase_nsk_jvmti`

This is much cleaner! Thank you, and thank you SonarCloud.

src/hotspot/share/prims/methodComparator.cpp line 262:

> 260: }
> 261: 
> 262: bool MethodComparator::pool_constants_same(int cpi_old, int cpi_new, ConstantPool* old_cp, ConstantPool* new_cp) {

Can these be const?

src/hotspot/share/prims/methodComparator.cpp line 67:

> 65: bool MethodComparator::args_same(Bytecodes::Code c_old, Bytecodes::Code c_new,
> 66:                                  BytecodeStream* s_old, BytecodeStream* s_new,
> 67:                                  ConstantPool* old_cp,  ConstantPool* new_cp) {

Can these be const pointers too?

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

Marked as reviewed by coleenp (Reviewer).

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


More information about the hotspot-dev mailing list