X-Ray Jam. June 9-15, 2025. In 8 days.

Handmade Hero Day 124

In day 124 the work queue looks like that

{
 ThreadInfo* thread_info = (ThreadInfo*)lpParameter;
 for (;;)
 {
  if (next_entry_to_do < entry_count)
  {
   int entry_index = InterlockedIncrement((LONG volatile)&next_entry_to_do) - 1;
   WorkQueueEntry* entry = entries + entry_index;
   printf("Thread %d: %s\n", thread_info->logical_thread_index, entry->string_to_print);
  }
 }
 
 return 0;
}

shouldn't we prevent an out of bond access to the WorkQueueEntry by verifying we have not an index greater than entry_count after InterlockedIncrement ?

Thanks


Edited by bewwys on

It seems that this was fixed in day 126.