public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Patryk Jakubowski <patrics@interia.pl>
To: linux-kernel@vger.kernel.org
Subject: Re: Invisible threads in 2.6.9
Date: Wed, 06 Oct 2004 12:14:12 +0200	[thread overview]
Message-ID: <4163C574.50805@interia.pl> (raw)
In-Reply-To: <4163A3E2.2060609@stud.feec.vutbr.cz>

Michal Schmidt wrote:

>
> It doesn't work for me:
>
> # ps aux | grep [t]hread
> michich   7447  0.0  0.0     0    0 pts/1    Zl+  09:43   0:00 
> [threadbug] <defunct>
> # ps auwxH | grep [t]hread
> #
>
> And I can't inspect /proc directly:
>
> Isn't it strange?
>
> Michal Schmidt
>

Yes. It is badly strange for me. It is not the bug in procps. procps 
scans the /proc tree for information, top and ps too. I know that I'm 
amateur programmer, but not kernel programmer.

When i run this example program (threadbug) and let its PID be 6024. Its 
first subthread can be PID 6025 (for example). The lider thread exits. 
And /proc/6024/task is inaccesible, ls shows it empty. 
/proc/6024/task/6025 should exist. However, cat /proc/6025/cmdline 
returns ./threadbug. But ls -d /proc/602? do not shows /proc/6025. Any 
way. I'm almost sure that /proc/6024/task/* should be visible. It is bug 
in procfs filesystem or buggy strategy to show tasks in /proc.



I put here my session with threadbug. Important lines are prefixed with "!".

  pat@pat:/tmp$ cat > threadbug.c
  #include <pthread.h>
  #include <unistd.h>
 
  void *run(void *arg)
  {
      for(;;);
  }
 
  int main()
  {
      pthread_t t;
      int i;
      for (i = 0; i < 10; ++i)
          pthread_create(&t, NULL, run, NULL);
      sleep(30);
      pthread_exit(NULL);
  }

  pat@pat:/tmp$ gcc -o threadbug -lpthread threadbug.c

  pat@pat:/tmp$ ./threadbug &
  [1] 6907

  pat@pat:/tmp$ date
  Wed Oct  6 11:37:41 CEST 2004

! pat@pat:/tmp$ ls /proc/6907/task    # threads are detectable
  6907  6908  6909  6910  6911  6912  6913  6914  6915  6916  6917

  pat@pat:/tmp$ ps m
    PID TTY      STAT   TIME COMMAND
   1647 pts/0    -      0:00 /bin/bash
      - -        Ss     0:00 -
   6019 pts/2    -      0:00 /bin/bash
      - -        Ss     0:00 -
   6035 pts/3    -      0:00 /bin/bash
      - -        Ss+    0:00 -
   6907 pts/2    -      0:00 ./threadbug
      - -        S      0:00 -
      - -        R      0:06 -
      - -        R      0:06 -
      - -        R      0:06 -
      - -        R      0:05 -
      - -        R      0:06 -
      - -        R      0:06 -
      - -        R      0:06 -
      - -        R      0:05 -
      - -        R      0:07 -
      - -        R      0:07 -
   6928 pts/2    -      0:00 ps m
      - -        R+     0:00 -

! pat@pat:/tmp$ date    # now leader thread is exited
!  Wed Oct  6 11:40:15 CEST 2004

  pat@pat:/tmp$ ls /proc/6907/task
!  ls: /proc/6907/task: No such file or directory    # no threads and 
other info

  pat@pat:/tmp$ ps m
    PID TTY      STAT   TIME COMMAND
   1647 pts/0    -      0:00 /bin/bash
      - -        Ss     0:00 -
   6019 pts/2    -      0:00 /bin/bash
      - -        Ss     0:00 -
   6035 pts/3    -      0:00 /bin/bash
      - -        Ss+    0:00 -
   6907 pts/2    -      0:00 [threadbug] <defunct>
   6942 pts/2    -      0:00 ps m
      - -        R+     0:00 -

!  pat@pat:/tmp$ cat /proc/69[01]?/cmdline   # where are the threads?

!  pat@pat:/tmp$ cat /proc/6907/cmdline    # where is info?

  pat@pat:/tmp$ cat /proc/6908/cmdline    # some info is hidden here
  ./threadbug

  pat@pat:/tmp$ cat /proc/6909/cmdline
  ./threadbug

  pat@pat:/tmp$ cat /proc/6910/cmdline
 ./threadbug

! pat@pat:/tmp$ cat /proc/6910/status    # and here
  Name:   threadbug
  State:  R (running)
  SleepAVG:       0%
! Tgid:   6907
! Pid:    6910   # this is PID of the thread of process 6907
  PPid:   6019
  TracerPid:      0
  Uid:    1000    1000    1000    1000
  Gid:    100     100     100     100
  FDSize: 256
  Groups: 4 5 24 29 33 44 100 1001
  VmSize:    83528 kB
  VmLck:         0 kB
  VmRSS:       456 kB
  VmData:    82076 kB
  VmStk:        12 kB
  VmExe:         1 kB
  VmLib:     83343 kB
!  Threads:        11    # 10 subthreads and 1 leader thread
  SigPnd: 0000000000000000
  ShdPnd: 0000000000000000
  SigBlk: 0000000000000000
  SigIgn: 0000000000000000
  SigCgt: 0000000080000000
  CapInh: 0000000000000000
  CapPrm: 0000000000000000
  CapEff: 0000000000000000
  pat@pat:/tmp$ kill %1
  pat@pat:/tmp$
  [1]+  Terminated              ./threadbug
  pat@pat:/tmp$


I have checked threadbug program ont RedHat Enterprise with 2.4.21 
kernel with NPTL 0.60. Threads was visible after leader thread exits and 
process become zombie state.

My configuration:
Kernel: 2.6.9-rc9, SMP/SMT, not preemptible
libc6-2.3.2

GNU_LIBPTHREAD_VERSION = NPTL 0.60
P4 Presscott processor, HT
gcc-3.4




----------------------------------------------------------------------
Portal INTERIA.PL zaprasza... >>> http://link.interia.pl/f17cb


  reply	other threads:[~2004-10-06 10:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <S268296AbUJDTjb/20041004193948Z+2396@vger.kernel.org>
2004-10-05 20:59 ` Invisible threads in 2.6.9 Patryk Jakubowski
2004-10-06  3:08   ` Nuno Silva
2004-10-06  7:50     ` Michal Schmidt
2004-10-06 10:14       ` Patryk Jakubowski [this message]
     [not found]         ` <20041006110721.GC4380@vana.vc.cvut.cz>
2004-10-06 11:36           ` Patryk Jakubowski
2004-10-06 14:58             ` Chris Friesen
2004-10-07  0:21 Albert Cahalan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4163C574.50805@interia.pl \
    --to=patrics@interia.pl \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox