LuciferYang opened a new issue, #13248:
URL: https://github.com/apache/gravitino/issues/13248

   **Version**
   main branch
   
   **Describe what's wrong**
   `clearShutdownHooks` reflectively removes entries from the JVM-global 
`ApplicationShutdownHooks.hooks` `IdentityHashMap` without holding the 
`ApplicationShutdownHooks` class monitor that `add()`/`remove()` synchronize 
on. A concurrent `Runtime.addShutdownHook` from any thread can corrupt the map 
or throw inside the JVM's shutdown machinery.
   
   **Error message and/or stacktrace**
   N/A: a data race with no deterministic stacktrace; the potential outcomes 
are map corruption or a 
`ConcurrentModificationException`/`NullPointerException` inside the JVM 
shutdown machinery.
   
   **How to reproduce**
   Call `clearShutdownHooks` while another thread calls 
`Runtime.getRuntime().addShutdownHook(...)`; the unsynchronized `removeIf` 
races with the JDK's synchronized `add`/`remove` on the shared map. The race is 
timing-dependent and not deterministically reproducible.
   
   **Additional context**
   The JDK's `ApplicationShutdownHooks.add`/`remove` are `static synchronized` 
on that class. Found during a code audit of the `catalog-common` module.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to