RFR: 8277441: CompileQueue::add fails with assert(_last->next() == __null) failed: not last

Tobias Hartmann thartmann at openjdk.java.net
Tue Nov 23 07:39:13 UTC 2021


On Mon, 22 Nov 2021 13:57:21 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:

> In the rare case that the compiler threads fail during initialization or the code cache is full and flushing is disabled, we completely disable JIT compilation and shut down the compiler runtime:
> https://github.com/openjdk/jdk/blob/2f4b5405f0b53782f3ed5274f68b31eb968efb6d/src/hotspot/share/compiler/compileBroker.cpp#L1813-L1817
> 
> In the process, we free all compiler queues and set `CompileQueue::_first` to `NULL` and put the `CompileTasks` on the free list: https://github.com/openjdk/jdk/blob/2f4b5405f0b53782f3ed5274f68b31eb968efb6d/src/hotspot/share/compiler/compileTask.cpp#L84
> 
> In rare cases, although compilation is disabled, another waiting thread might still call `CompileQueue::add`. That code then fails because `_last != NULL` and `_last->next()` is set to `_task_free_list`. 
> https://github.com/openjdk/jdk/blob/2f4b5405f0b53782f3ed5274f68b31eb968efb6d/src/hotspot/share/compiler/compileBroker.cpp#L362-L369
> 
> The fix is to set `_last` to `NULL` in `CompileQueue::free_all`. Adding to the compile queue then succeeds which is harmless because queues have only been freed to make the compiler threads exit faster:
> https://github.com/openjdk/jdk/blob/2f4b5405f0b53782f3ed5274f68b31eb968efb6d/src/hotspot/share/compiler/compileBroker.cpp#L1823
> 
> The test that triggered this will be added with [PR 6364](https://github.com/openjdk/jdk/pull/6364). I verified that it now passes.
> 
> Thanks,
> Tobias

Thanks for the review, Nils!

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

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


More information about the hotspot-compiler-dev mailing list