RFR: 8274794: Print all owned locks in hs_err file

Coleen Phillimore coleenp at openjdk.java.net
Fri Oct 15 12:23:55 UTC 2021


On Fri, 15 Oct 2021 06:13:28 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> See CR for details.  This saves the created mutex in a mutex_array during Mutex construction so that all Mutex, not just the ones in mutexLocker.cpp can be printed in the hs_err file.  ThreadCritical is used to protect the mutex_array, and to avoid UB should be used when printing the owned locks, but since that is done during error handling, this seemed better not to lock during error handling.  There's 0 probability that another thread will be creating a lock during this error handling anyway.
>> Tested with tier1-8.
>
> src/hotspot/share/runtime/mutex.cpp line 278:
> 
>> 276:     _mutex_array = new (ResourceObj::C_HEAP, mtThread) GrowableArray<Mutex*>(128, mtThread);
>> 277:   }
>> 278:   ThreadCritical tc;
> 
> You could avoid the TC on first call by duplicating the push line after the allocation and returning. This also avoid any potential issue with TC needing more initialization than has been done when this is first called.

Ok, seems like a good idea.

> test/hotspot/jtreg/runtime/ErrorHandling/ErrorFileLocksTest.java line 41:
> 
>> 39: import java.util.regex.Pattern;
>> 40: 
>> 41: public class ErrorFileLocksTest {
> 
> Nit: could you s/Locks/Mutex please. My brain parses this a Filelock test. :)

I like TestErrorFileMutex.java with Test at the beginning. That matches other names in that directory.

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

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


More information about the hotspot-dev mailing list