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

Tobias Hartmann thartmann at openjdk.java.net
Mon Nov 22 14:08:59 UTC 2021


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

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

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

Changes: https://git.openjdk.java.net/jdk/pull/6503/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=6503&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8277441
  Stats: 1 line in 1 file changed: 1 ins; 0 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/6503.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/6503/head:pull/6503

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


More information about the hotspot-compiler-dev mailing list