What if we add something like done to the by-value variables list?

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
void multi_dns_conc(
    
size_t N, char **names, struct addrinfo **infos )
{
    
size_t i, done = 0;
    
semaphore_t done_sem;
    
sem_init( &done_sem, 0 );
    
for( i = 0; i < N; ++i )
    
{
        
activate ( i, done )
        
{
            
assert( 0 == getaddrinfo(
                
names[i], NULL, NULL, &infos[i] ) );
            
if( ( ++done ) == N )
                
sem_inc( &done_sem );
        
}
    
}
    
sem_dec( &done_sem );
}

This should be a relatively easy bug to find and fix. All of the lookup activities will get their own copy of done (each of which will be initialized to 0). None of the activities will perform the semaphore increment on line 14, so the main activity will be stuck forever.