<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://sourceware.org/bugzilla/page.cgi?id=bugzilla.dtd">

<bugzilla version="4.4+"
          urlbase="http://sourceware.org/bugzilla/"
          
          maintainer="overseers@sourceware.org"
>

    <bug>
          <bug_id>10879</bug_id>
          
          <creation_ts>2009-10-31 17:25:00 +0000</creation_ts>
          <short_desc>Rapidly exiting threads cause problems on attach+continue on Solaris</short_desc>
          <delta_ts>2009-10-31 17:25:21 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>gdb</product>
          <component>threads</component>
          <version>unknown</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>UNCONFIRMED</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>7.1</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Paul Pluzhnikov">ppluzhnikov</reporter>
          <assigned_to name="Not yet assigned to anyone">unassigned</assigned_to>
          <cc>gdb-prs</cc>
          <cf_gcchost>i386-pc-solaris2.10</cf_gcchost>
          <cf_gcctarget>i386-pc-solaris2.10</cf_gcctarget>
          <cf_gccbuild>i386-pc-solaris2.10</cf_gccbuild>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>39435</commentid>
    <comment_count>0</comment_count>
    <who name="Paul Pluzhnikov">ppluzhnikov</who>
    <bug_when>2009-10-31 17:25:21 +0000</bug_when>
    <thetext>This is a logical continuation of PR10757.

Test case:

/// --- cut ---

/* compile with &quot;gcc -g -pthreads manythreads.c -o manythreads&quot; */
#include &lt;assert.h&gt;
#include &lt;pthread.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;stdio.h&gt;
#include &lt;unistd.h&gt;

void *foo (void)
{
  // set breakpoint here
  usleep(1);
  return NULL;
}

void *fn (void *p)
{
  pthread_t tid = (pthread_t) p;
  int rc;

  if (p != NULL)
    assert (pthread_join (tid, NULL) == 0);

  while ((rc = pthread_create (&amp;tid, NULL, fn, (void*) pthread_self ())) != 0)
    fprintf (stderr, &quot;unexpected error from pthread_create: %d\n&quot;, rc);
  return foo();
}

int main (int argc, char *argv[])
{
  int i, n_threads = 100;

  if (argc &gt; 1)
    n_threads = atoi (argv[1]);

  for (i = 0; i &lt; n_threads; ++i)
    {
      pthread_t tid;

      while (pthread_create (&amp;tid, NULL, fn, NULL) != 0)
        sleep (1);
    }
  sleep (300);
  exit (0);
}

/// --- cut ---

./manythreads &amp; sleep 1 &amp;&amp; ./gdb -nx ./manythreads $!
[1] 12880
GNU gdb (GDB) 7.0.50.20091031-cvs
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later &lt;http://gnu.org/licenses/gpl.html&gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type &quot;show copying&quot;
and &quot;show warranty&quot; for details.
This GDB was configured as &quot;i386-pc-solaris2.10&quot;.
For bug reporting instructions, please see:
&lt;http://www.gnu.org/software/gdb/bugs/&gt;...
Reading symbols from /export/home/paul/tmp/manythreads...done.
Attaching to program `/export/home/paul/tmp/manythreads&apos;, process 12880
[New process 12880]
Retry #1:
Retry #2:
Retry #3:
Retry #4:
Reading symbols from /lib/libpthread.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib/libpthread.so.1
Reading symbols from /lib/libc.so.1...(no debugging symbols found)...done.
[Thread debugging using libthread_db enabled]
[New LWP    7656        ]
[New LWP    7614        ]
...
[New Thread 7459        ]
[New Thread 7458        ]
[New Thread 7457        ]
Loaded symbols for /lib/libc.so.1
Reading symbols from /lib/ld.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib/ld.so.1
[Switching to Thread 1 (LWP 1)]
0xfef19735 in ___nanosleep () from /lib/libc.so.1
(gdb) b foo
procfs: fetch_registers, get_gregs line 3800, /proc/12880/lwp/7457: No such file
or directory.

Another failure I&apos;ve seen:

(gdb) b foo
Breakpoint 1 at 0x8050ab2: file manythreads.c, line 10.
(gdb) commands 1
Type commands for when breakpoint 1 is hit, one per line.
End with a line saying just &quot;end&quot;.
&gt;silent
&gt;c
&gt;end
(gdb) c
Continuing.
[LWP    2236         exited]
[New LWP    2247        ]
[LWP    2235         exited]
[LWP    2246         exited]
sol_thread_fetch_registers: td_ta_map_id2thr: no thread can be found to satisfy
query</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>39440</commentid>
    <comment_count>1</comment_count>
    <who name="Pedro Alves">palves</who>
    <bug_when>2009-10-31 21:43:51 +0000</bug_when>
    <thetext>Subject: Re:  New: Rapidly exiting threads cause problems on attach+continue on Solaris

On Saturday 31 October 2009 17:25:22, ppluzhnikov at google dot com wrote:
&gt; Another failure I&apos;ve seen:
&gt; 
&gt; (gdb) b foo
&gt; Breakpoint 1 at 0x8050ab2: file manythreads.c, line 10.
&gt; (gdb) commands 1
&gt; Type commands for when breakpoint 1 is hit, one per line.
&gt; End with a line saying just &quot;end&quot;.
&gt; &gt;silent
&gt; &gt;c
&gt; &gt;end
&gt; (gdb) c
&gt; Continuing.
&gt; [LWP    2236         exited]
&gt; [New LWP    2247        ]
&gt; [LWP    2235         exited]
&gt; [LWP    2246         exited]
&gt; sol_thread_fetch_registers: td_ta_map_id2thr: no thread can be found to satisfy
&gt; query

May be related to PR7860.
</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>