JDK-8231356 : Fix broken ResourceObj::operator new[] in debug builds
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 14
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-09-23
  • Updated: 2021-09-07
  • Resolved: 2021-09-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 18
18 masterFixed
Related Reports
Blocks :  
Relates :  
Description
ResourceObj::operator new[] calls ResourceObj::operator new (non array version). In debug builds, each resource object 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.
Comments
Changeset: 3cd95a29 Author: Leo Korinth <lkorinth@openjdk.org> Date: 2021-09-07 08:23:32 +0000 URL: https://git.openjdk.java.net/jdk/commit/3cd95a2932ab6a2cb39322354f7ad181de8bfc9e
07-09-2021

Plan is to declare the problematic operators as deleted.
08-05-2020

ILW = MLM = P4
04-02-2020