Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Cc: Hui Zhu <hui_zhu@mentor.com>, Pedro Alves <palves@redhat.com>
Subject: [testsuite patch] race: server-kill.exp: Connection reset by peer  [Re: [patch+7.6] Fix 7.5 regression crashing GDB if gdbserver dies]
Date: Mon, 08 Apr 2013 07:17:00 -0000	[thread overview]
Message-ID: <20130406192632.GA8832@host2.jankratochvil.net> (raw)
In-Reply-To: <20130322191841.GA29259@host2.jankratochvil.net>

[-- Attachment #1: Type: text/plain, Size: 1919 bytes --]

On Fri, 22 Mar 2013 20:18:41 +0100, Jan Kratochvil wrote:
> +set server_pid [exp_pid -i [board_info target fileid]]
> +remote_exec target "kill -9 $server_pid"
> +
> +gdb_test "step" "Remote connection closed"

Getting occasionally randomly:
	Remote communication error.  Target disconnected.: Connection reset by peer.
	(gdb) FAIL: gdb.server/server-kill.exp: tstatus

(it was FAILing on "step" before, "tstatus" vs. "step" does not matter)

I even Googled one may get ECONNRESET by writing into a closed TCP socket:
	http://stackoverflow.com/questions/2974021/what-does-econnreset-mean-in-the-context-of-an-af-local-socket

But I was unable to reproduce it myself (kernel-3.8.4-202.fc18.x86_64) with
the attached testcase:
	sleeping ... done
	write ok
	ssize=0
	read ok
	send: send.c:53: main: Unexpected error: Broken pipe.
	Aborted
by:
 * nc -l 5000
 * ./send (starts sleeping)
 * kill -9 `pidof ncat` (Fedora nc is ncat)
 * # send resumes sleeping

I get at most EPIPE but never ECONNRESET.  send vs. write and recv vs. read
also make no difference there.

With no answer I will check in this patch as this issue seems unrelated to the
problem, GDB still works properly even with ECONNRESET.  I was just curious.


Jan


gdb/testsuite/
2013-04-06  Jan Kratochvil  <jan.kratochvil@redhat.com>

* gdb.server/server-kill.exp (tstatus): Permit also ECONNRESET
	response.

diff --git a/gdb/testsuite/gdb.server/server-kill.exp b/gdb/testsuite/gdb.server/server-kill.exp
index 1b48152..75c9627 100644
--- a/gdb/testsuite/gdb.server/server-kill.exp
+++ b/gdb/testsuite/gdb.server/server-kill.exp
@@ -42,4 +42,4 @@ remote_exec target "kill -9 $server_pid"
 
 # Force GDB to talk with GDBserver, so that we can get the
 # "connection closed" error.
-gdb_test "tstatus" "Remote connection closed"
+gdb_test "tstatus" {Remote connection closed|Remote communication error\.  Target disconnected\.: Connection reset by peer\.}

[-- Attachment #2: send.c --]
[-- Type: text/plain, Size: 1333 bytes --]

#define _GNU_SOURCE 1
#include <sys/socket.h>
#include <assert.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>

static volatile int piped;
static void handler(int signo) {
  piped=1;
}

int main (void) {
  setbuf(stdout,NULL);
  signal(SIGPIPE,handler);
  int fd=socket(PF_INET,SOCK_STREAM,0);
  assert(fd!=-1);
  struct sockaddr_in addr;
  memset(&addr,0,sizeof addr);
  addr.sin_family=AF_INET;
  addr.sin_addr.s_addr=htonl(INADDR_LOOPBACK);
  addr.sin_port=htons(5000);
  int i=connect(fd,(struct sockaddr *)&addr,sizeof(addr));
  assert(i==0);
  char charbuf='a';
  ssize_t ssize=send(fd,&charbuf,1,0);
  assert(ssize==1);
  fputs("sleeping ...",stdout);
  sleep(5);
  charbuf='b';
  puts(" done");
  errno=0;
//  ssize=send(fd,&charbuf,1,0);
  ssize=write(fd,&charbuf,1);
  assert_perror(errno);
  assert(ssize==1);
//  puts("send ok");
  puts("write ok");
  errno=0;
//  ssize=recv(fd,&charbuf,1,0);
  ssize=read(fd,&charbuf,1);
  assert_perror(errno);
  printf("ssize=%zd\n",ssize);
  assert(ssize==0);
//  puts("recv ok");
  puts("read ok");
  errno=0;
  ssize=send(fd,&charbuf,1,0);
//  ssize=write(fd,&charbuf,1);
  assert_perror(errno);
  assert(ssize==1);
  puts("send ok");
//  puts("write ok");
  if (piped)
    puts("SIGPIPE");
  return 0;
}

  parent reply	other threads:[~2013-04-06 19:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-15 19:55 [patch+7.6] Fix 7.5 regression crashing GDB if gdbserver dies Jan Kratochvil
2013-03-22 13:04 ` Pedro Alves
2013-03-22 20:29   ` Jan Kratochvil
2013-03-22 20:45     ` Pedro Alves
2013-03-22 20:55       ` Tom Tromey
2013-03-23 10:51         ` Pedro Alves
2013-03-23 16:25           ` Tom Tromey
2013-03-23 18:31       ` [commit+7.6] " Jan Kratochvil
2013-03-23 22:49         ` Pedro Alves
2013-04-02 13:41         ` Yao Qi
2013-04-02 15:20           ` Jan Kratochvil
2013-04-04 11:09             ` Yao Qi
2013-04-08  7:17     ` Jan Kratochvil [this message]
2013-04-09 15:44       ` [testsuite patch] race: server-kill.exp: Connection reset by peer [Re: [patch+7.6] Fix 7.5 regression crashing GDB if gdbserver dies] Pedro Alves
2013-04-09 16:00         ` [commit+7.6] " Jan Kratochvil

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=20130406192632.GA8832@host2.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=hui_zhu@mentor.com \
    --cc=palves@redhat.com \
    /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