Skip to content

Commit

Permalink
Merge pull request #74759 from AThousandShips/rid_overflow
Browse files Browse the repository at this point in the history
Handle RID validator overflow
  • Loading branch information
akien-mga committed Jun 20, 2023
2 parents dbe8712 + e344bab commit 7dc69ff
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/templates/rid_owner.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class RID_Alloc : public RID_AllocBase {
uint32_t free_element = free_index % elements_in_chunk;

uint32_t validator = (uint32_t)(_gen_id() & 0x7FFFFFFF);
CRASH_COND_MSG(validator == 0x7FFFFFFF, "Overflow in RID validator");
uint64_t id = validator;
id <<= 32;
id |= free_index;
Expand Down Expand Up @@ -238,7 +239,7 @@ class RID_Alloc : public RID_AllocBase {

uint32_t validator = uint32_t(id >> 32);

bool owned = (validator_chunks[idx_chunk][idx_element] & 0x7FFFFFFF) == validator;
bool owned = (validator != 0x7FFFFFFF) && (validator_chunks[idx_chunk][idx_element] & 0x7FFFFFFF) == validator;

if (THREAD_SAFE) {
spin_lock.unlock();
Expand Down

0 comments on commit 7dc69ff

Please sign in to comment.