RFR: 8295851: Do not use ttyLock in BytecodeTracer::trace [v3]

David Holmes dholmes at openjdk.org
Tue Jun 24 02:53:33 UTC 2025


On Mon, 23 Jun 2025 20:56:46 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> If multiple threads change the value of _current_method, the method printing will print the method name again.  That's a benign race.
>
> So actually this wasn't more racy than what was there in this respect.  You could change the global method before taking the ttyLock and for multiple threads, this would claim that the current method had changed.   The old code also had shared state for BytecodeTracer.  Now this uses a local instance, which can then print the bytecode at the given location.

So the old code (mis)used a shared `ByteCodeTracer` instance, and the new code gives each use a local `ByteCodeTracer` but seeds it from the global shared field. So I agree the level of raciness seems unchanged.

But printing an unrelated method name still seems a bad thing to do. ??

BTW it is also very confusing to give the global variable the same name as the private field in `ByteCodeTracer`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25915#discussion_r2162858904


More information about the hotspot-runtime-dev mailing list