In the following code, the int type of return value of find_index_of_JavaThread() is casted and assigned to the uint variable i. It has possibility to cause underflow. In the case where java_thread is not found by find_index_of_JavaThread(), it returns -1. So underflow happens if ThreadsList::remove_thread() is called in some inappropriate situation.
open/src/hotspot/share/runtime/threadSMR.cpp
ThreadsList *ThreadsList::remove_thread(ThreadsList* list, JavaThread* java_thread) {
...
uint i = (uint)list->find_index_of_JavaThread(java_thread);
assert(i < list->_length, "did not find JavaThread on the list");
const uint index = i;
const uint new_length = list->_length - 1;
const uint head_length = index;
const uint tail_length = (new_length >= index) ? (new_length - index) : 0;
ThreadsList *const new_list = new ThreadsList(new_length);
...
open/src/hotspot/share/runtime/threadSMR.cpp
ThreadsList *ThreadsList::remove_thread(ThreadsList* list, JavaThread* java_thread) {
...
uint i = (uint)list->find_index_of_JavaThread(java_thread);
assert(i < list->_length, "did not find JavaThread on the list");
const uint index = i;
const uint new_length = list->_length - 1;
const uint head_length = index;
const uint tail_length = (new_length >= index) ? (new_length - index) : 0;
ThreadsList *const new_list = new ThreadsList(new_length);
...