Skip to content

Commit

Permalink
proccontrol: fix double-increment while erasing a dead process
Browse files Browse the repository at this point in the history
In the attach loop over waitfor_startup(), processes which fail are
erased from the set.  However, the iterator was getting incremented
again, which will skip the next process or even cause undefined behavior
if already at the end of the list.

With GCC 6.2.1, that UB manifested as an infinite loop on a self-
referential rbtree node.

The simple solution is to `continue` the loop after `erase(i++)`, as is
done in many other places with this same pattern.
  • Loading branch information
cuviper committed Nov 18, 2016
1 parent 64edc81 commit 8011105
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions proccontrol/src/process.C
Expand Up @@ -453,6 +453,7 @@ bool int_process::attach(int_processSet *ps, bool reattach)
pthrd_printf("Error waiting for attach to %d\n", proc->pid);
procs.erase(i++);
had_error = true;
continue;
}
i++;
}
Expand Down

0 comments on commit 8011105

Please sign in to comment.