Bug 203770 - devel/gdb: Error "fbsd_thread_resume: no thread to satisfy query" when debugging pthread program with fork
Summary: devel/gdb: Error "fbsd_thread_resume: no thread to satisfy query" when debugg...
Status: Closed DUPLICATE of bug 203661
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords: easy, needs-qa, patch
Depends on:
Blocks:
 
Reported: 2015-10-14 14:44 UTC by nkoch
Modified: 2015-10-19 09:51 UTC (History)
2 users (show)

See Also:
luca.pizzamiglio: maintainer-feedback+


Attachments
Fixing patch (646 bytes, patch)
2015-10-16 15:57 UTC, luca.pizzamiglio
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description nkoch 2015-10-14 14:44:20 UTC
**** I wrote this simple test program:

#include <time.h>
#include <sys/types.h>
#include <unistd.h>
#include <pthread.h>
#include <pthread_np.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

static void *routine (void *arg)
{
  pid_t pid;
  int status;
  printf ("thread started\n");
  pid = fork ();
  if (pid == 0)
  {
    printf ("child started\n");
    sleep (1);
    printf ("child finished\n");
    _exit (0);
  }
  else
  {
    printf ("parent waiting\n");
    wait (&status);
    printf ("child exited\n");
  };
  return NULL;
}

int main ()
{
  pthread_attr_t attr;
  pthread_t thread;

  pthread_attr_init (&attr);
  pthread_create (&thread, &attr, routine, NULL);
  printf ("thread created\n");
  pthread_join (thread, NULL);

  return 0;
}

**** I compiled with cc -g
**** Here is the output from a debugging session with /usr/bin/gdb:

(gdb) GNU gdb 6.1.1 [FreeBSD]
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-marcel-freebsd"...
(gdb) r
Starting program: /usr/home/nk/test/a.out
[New LWP 101624]
thread created
thread started
parent waiting
child exited
[New Thread 28404300 (LWP 101624/a.out)]
[New Thread 28404900 (LWP 126633/a.out)]
[Thread 28404900 (LWP 126633/a.out) exited]

Program exited normally.
(gdb) q

**** It works as expected.
**** Here is the output from a debugging session with /usr/local/bin/gdb710:

GNU gdb (GDB) 7.10 [GDB v7.10 for FreeBSD]
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i386-portbld-freebsd9.1".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./a.out...done.
(gdb) r
Starting program: /usr/home/nk/test/a.out
[New Thread 28404300 (LWP 106355)]
[New Thread 28404900 (LWP 123560)]
[New process 69475]
0x280f261b in fork () from /lib/libc.so.7
fbsd_thread_resume: no thread to satisfy query
(gdb) c
Continuing.
0x280f261b in fork () from /lib/libc.so.7
fbsd_thread_resume: no thread to satisfy query
(gdb) q
A debugging session is active.

	Inferior 1 [process 69475] will be killed.

Quit anyway? (y or n) y
thread created
thread started
parent waiting
child exited

********

I am seeing this behaviour under 9.1 with gdb from ports
and under 10.2 with gdb installed via pkg.
Same behaviour with gcc/clang.
Comment 1 luca.pizzamiglio 2015-10-16 15:57:48 UTC
Created attachment 162125 [details]
Fixing patch

This patch should solve the problem.
Please run some test with it applied, if you can.
Comment 2 Kubilay Kocak freebsd_committer freebsd_triage 2015-10-19 08:50:47 UTC
Luca, if the reporter does not get back to you, please set maintainer-approval (+) on the patch when you are ready for it to be committed.
Comment 3 nkoch 2015-10-19 09:20:14 UTC
Sorry for the delay.
Could not test it before this morning (CET).
As I can see so far it works for me.
Comment 4 luca.pizzamiglio 2015-10-19 09:41:50 UTC
(In reply to Kubilay Kocak from comment #2)

Thanks for the explanation, the maintainer feedback is the only knob that I can always use and I should use it more often.

BTW, this bug report and the Bug 203661 are the same, so I would love to close it (but I've no right to change the bug status).
Comment 5 Kubilay Kocak freebsd_committer freebsd_triage 2015-10-19 09:44:05 UTC
@Luca, so this bug is a duplicate of bug 203661 (which has been resolved/close), am I understanding correctly?

If so I can close this issue a duplicate of bug 203661. If however, the patch attached here fixes something outstanding, then the two bugs cannot be duplicates (by definition).

Please provide instructions and I'll be happy to triage the issues in question accordingly
Comment 6 luca.pizzamiglio 2015-10-19 09:49:56 UTC
(In reply to Kubilay Kocak from comment #5)

Hi Kubilay,
The patch attached is here is the same as the one in bug 203661.
So, please, close this bug as duplicated of bug 203661.

Thank you very much for the support
Comment 7 Kubilay Kocak freebsd_committer freebsd_triage 2015-10-19 09:51:14 UTC
My pleasure Luca, you're welcome

*** This bug has been marked as a duplicate of bug 203661 ***