RFR: 8231356: Fix broken ResourceObj::operator new[] in debug builds [v2]

Leo Korinth lkorinth at openjdk.java.net
Wed Aug 11 11:36:43 UTC 2021


> ResourceObj::operator new[] calls ResourceObj::operator new (non array version). In debug builds, each resource object (on C_HEAP) will be initialized with set_allocation_type() (which is correct). What is not correct is that the constructor (and thus) set_allocation_type() is called on the array itself (which is not a ResourceObj). This initialization will be partially overwritten by the header that keeps track of the array size. When the array destructor later is called, it will also chain call the non-array destructor. In debug builds the verification of _allocation_t[0] will fail as it has been overwritten by the code that keeps track of the array size.
> 
> The following assert will fail:
> assert(~(_allocation_t[0] | allocation_mask) == (uintptr_t)this, "lost resource object");
> 
> The reason that it has not been detected is that no one uses ResourceObj::operator new[] on resource objects with C_HEAP storage.

Leo Korinth has updated the pull request incrementally with one additional commit since the last revision:

  Remove all other new [] operators in RsourceObj and the delete [] operator as well

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

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/5055/files
  - new: https://git.openjdk.java.net/jdk/pull/5055/files/8123c6d4..a0833384

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=5055&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=5055&range=00-01

  Stats: 26 lines in 2 files changed: 0 ins; 22 del; 4 mod
  Patch: https://git.openjdk.java.net/jdk/pull/5055.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/5055/head:pull/5055

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


More information about the hotspot-runtime-dev mailing list