RFR: 8310275: Bug in assignment operator of ReservedMemoryRegion [v2]

Thomas Stuefe stuefe at openjdk.org
Wed Jul 26 09:03:54 UTC 2023


On Wed, 19 Jul 2023 13:00:10 GMT, Ralf Schmelter <rschmelter at openjdk.org> wrote:

>> 8310275: Bug in assignment operator of ReservedMemoryRegion
>
> Ralf Schmelter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fixed test name

Fix itself is fine, obviously. This is an old bug and we should backport it.

I propose a simpler fix that tests the fixed assignment directly:


TEST_VM(NMT, ReservedRegionCopy) {
  address dummy1 = (address)0x10000000;
  ReservedMemoryRegion region1(dummy1, os::vm_page_size(), CALLER_PC);
  region1.add_committed_region(dummy1, os::vm_page_size(), CALLER_PC);

  address dummy2 = (address)0x20000000;
  ReservedMemoryRegion region2(dummy2, os::vm_page_size(), CALLER_PC);
  region2.add_committed_region(dummy2, os::vm_page_size(), CALLER_PC);

  region2 = region1;

  CommittedRegionIterator itr = region2.iterate_committed_regions();
  const CommittedMemoryRegion* rgn = itr.next();
  ASSERT_EQ(rgn->base(), dummy1); // Now we should see dummy1
  rgn = itr.next();
  ASSERT_EQ(rgn, (const CommittedMemoryRegion*)nullptr); // and nothing else
}


Tested, fails with stock and succeeds with your patch.

Could be probably dumbed down even further if we extended the RMR interface to expose committed regions.

Could also be extended to check that the other properties are copied correctly.

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

PR Review: https://git.openjdk.org/jdk/pull/14440#pullrequestreview-1547185239


More information about the hotspot-runtime-dev mailing list