RFR: 8302670: use-after-free related to PhaseIterGVN interaction with Unique_Node_List and Node_Stack [v2]
Justin King
jcking at openjdk.org
Tue May 16 16:22:10 UTC 2023
On Wed, 10 May 2023 12:44:20 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> src/hotspot/share/libadt/vectset.hpp line 57:
>>
>>> 55: VectorSet(Arena* arena);
>>> 56:
>>> 57: // Allow move constructor for && (eg. capture return of function)
>>
>> It's not completely clear yet to me why this is required and how it correlates with `NONCOPYABLE` but I leave this to the experts :)
>
> I took this from @jcking . From what I understand:
> `NONCOPYABLE` disables the copy constructor (`&`) and move operator. Somehow, this also disables the move constructor (`&&`). Re-enabling that one allows things like returning local containers, and capturing them via that move constructor.
>
> Unique_Node_List some_function() {
> Unique_Node_List local_worklist;
> // do stuff
> return local_worklist;
> }
>
> void other_function() {
> Unique_Node_List capture_worklist = some_function();
> // capture_worklist has its scope widened to this function
> }
>
> But if someone has a more detailed explanation, I'm glad to hear it ;)
https://en.cppreference.com/w/cpp/language/move_constructor details this a bit by referencing the standard. When you explicitly define or delete the copy constructor, the move constructor is no longer implicitly defined and you have to explicitly default it or define it.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13833#discussion_r1195403638
More information about the hotspot-dev
mailing list