• Evgenii Shatokhin's avatar
    dump: check for conflicts with the dead processes · c4cf5f0b
    Evgenii Shatokhin authored
    It may happen that a process has completed but its files in /proc/PID/
    are still open by another process (see remap_dead_pid test from zdtm
    suite, for example).
    
    If the PID number has been given to some newer thread since then, this
    can be problematic. If that thread is the main thread of some process,
    it seems to be handled OK on restore. However, if it is a secondary
    thread, restore fails with an error like:
    
      pie: Error (pie/restorer.c:439): Thread pid mismatch 4404/4403
    
    This is because open_remap_dead_process() adds a helper with PID 4403 to
    restore /proc/4403/* and that clashes with the thread's PID.
    
    It seems reasonable to detect such things at the checkpoint stage and
    refuse to dump, rather than to fail during restore.
    
    v.3:
    * Loop over dead_pids[] first: the array is likely to be empty.
      Note that it is still needed to iterate over the threads explicitly
      because pstree contains no items for the threads at that point.
    
    v.2:
    * Check for conflicts after all tasks have been dumped. One cannot rely
      on any particular order of tasks being dumped.
    Signed-off-by: 's avatarEvgenii Shatokhin <eshatokhin@virtuozzo.com>
    Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
    c4cf5f0b
cr-dump.c 36.2 KB