public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [pushed] gdb.threads/clone-thread_db.c: Add missing includes and fix pthread_join call
Date: Wed, 04 Mar 2015 09:14:00 -0000	[thread overview]
Message-ID: <1425460468-24235-1-git-send-email-palves@redhat.com> (raw)

This fixes:

> gdb compile failed, /gdb/testsuite/gdb.threads/clone-thread_db.c: In function 'main':
> /gdb/testsuite/gdb.threads/clone-thread_db.c:67:3: warning: implicit declaration of function 'alarm' [-Wimplicit-function-declaration]
>    alarm (300);
>    ^
> /gdb/testsuite/gdb.threads/clone-thread_db.c:69:3: warning: implicit declaration of function 'pthread_create' [-Wimplicit-function-declaration]
>    pthread_create (&child, NULL, thread_fn, NULL);
>    ^
> /gdb/testsuite/gdb.threads/clone-thread_db.c:70:3: warning: implicit declaration of function 'pthread_join' [-Wimplicit-function-declaration]
>    pthread_join (child);
>    ^

And then adding the missing headers revealed the pthread_join call was
incorrect.  This probably fixes the crash we see on ppc64be, e.g., at

 https://sourceware.org/ml/gdb-testers/2015-q1/msg04415.html

the logs there show:

 ...
 Program received signal SIGSEGV, Segmentation fault.
 [Switching to Thread 0x3fffb7ff54a0 (LWP 9275)]
 0x00003fffb7f3ce74 in .pthread_join () from /lib64/libpthread.so.0
 (gdb) FAIL: gdb.threads/clone-thread_db.exp: continue to end
 ...

Tested on x86_64 Fedora 20.

gdb/testsuite/
2015-03-04  Pedro Alves  <palves@redhat.com>

	* gdb.threads/clone-thread_db.c: Include unistd.h and pthread.h.
	(main): Pass missing retval argument to pthread_join call.
---
 gdb/testsuite/ChangeLog                     | 5 +++++
 gdb/testsuite/gdb.threads/clone-thread_db.c | 4 +++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 3b7bf7d..eb1b9ea 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-04  Pedro Alves  <palves@redhat.com>
+
+	* gdb.threads/clone-thread_db.c: Include unistd.h and pthread.h.
+	(main): Pass missing retval argument to pthread_join call.
+
 2015-03-02  Pedro Alves  <palves@redhat.com>
 
 	* gdb.threads/thread-execl.exp (do_test): Handle non-stop.
diff --git a/gdb/testsuite/gdb.threads/clone-thread_db.c b/gdb/testsuite/gdb.threads/clone-thread_db.c
index 4356d2f..e8dc7c3 100644
--- a/gdb/testsuite/gdb.threads/clone-thread_db.c
+++ b/gdb/testsuite/gdb.threads/clone-thread_db.c
@@ -24,6 +24,8 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <unistd.h>
+#include <pthread.h>
 
 #define STACK_SIZE 0x1000
 
@@ -67,7 +69,7 @@ main (int argc, char **argv)
   alarm (300);
 
   pthread_create (&child, NULL, thread_fn, NULL);
-  pthread_join (child);
+  pthread_join (child, NULL);
 
   return 0;
 }
-- 
1.9.3

                 reply	other threads:[~2015-03-04  9:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1425460468-24235-1-git-send-email-palves@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).