wait: No child processes

Łukasz Michalik lmi at ift.uni.wroc.pl
Thu Nov 17 09:25:26 UTC 2011


I'm currently debugging an issue in sydbox wrt recent linux kernels.
I initially thought strace wasn't affected by it, but then debian bug
#622863 [1] made me investigate further, althought it's impossible to
say what version was that user using.  It seems that unreleased code
clean up in HEAD exposes the bug, namely the 19cdada5b commit.

The bug only happens on recent linux.  I've bisected the kernel and
found that it was introduced by 9b84cca2564b9 [2] in linux.git, so
pretty much everything since 3.0-rc2 is affected.

I'm attaching a testcase that makes strace -f fail within seconds
(compile with g++ -std=c++0x -pthread); it just fires whole bunch of
threads that fork and wait for exiting children.  The test case is
perverse, but same would happen if one would try to compile say gcc
under strace with considerable number of paraller jobs for long

[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=622863
[2] https://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=commit;h=9b84cca2564b9a5b2d064fb44d2a55a5b44473a0

Łukasz P. Michalik
-------------- next part --------------
#include <cerrno>
#include <cstdlib>
#include <cstring>
#include <list>
#include <iostream>
#include <thread>
#include <sys/sysinfo.h>
#include <sys/wait.h>
#include <unistd.h>

void worker()
  while (true)
      pid_t p(fork());
      if (-1 == p)
	  std::cout << "Failed to fork: " << std::strerror(errno) << std::endl;

      if (0 == p)
	  int stat_loc;
	  int s(waitpid(p, &stat_loc, 0));
	  if (-1 == s)
	      std::cout << "Failed to wait: " << std::strerror(errno) << std::endl;

int main()
  const int pool_size(get_nprocs() * 4);
  std::cout << "Poolsize: " << pool_size << std::endl;

  std::list<std::thread> pool;

  for (int i(0); i != pool_size; ++i)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20111117/8b42fb1f/attachment.bin>

More information about the Strace-devel mailing list