JDK-8293346 : Add NoThreadCurrentMark to simulate non-attached threads
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 20
  • Priority: P4
  • Status: Resolved
  • Resolution: Won't Fix
  • Submitted: 2022-09-05
  • Updated: 2022-12-05
  • Resolved: 2022-12-05
Related Reports
Relates :  
Description
When working on JDK-8293344, I needed a way to verify that the fix actually worked and that I had removed all usages of ResourceArea memory inside an extend.

For that, a NoThreadCurrentMark was useful. It temporarily sets the current Thread* to NULL for the extend. Any use of Thread::current below that mark will now crash or assert.

This can be used for two things:
- guard code that is supposed to be safe for non-attached threads (os::malloc, stack printing, UL etc) against accidental usage of Thread::current() (e.g. resource area allocation)
- in gtests, simulate a non-attached thread to cover code that behaves differently with Thread::current()==NULL.
Comments
See Review - idea was received without much enthusiasm
05-12-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/10178 Date: 2022-09-06 06:37:35 +0000
07-09-2022