delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/10/27/08:12:21

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_NEUTRAL
X-Spam-Check-By: sourceware.org
Message-ID: <4EA94A7B.2070907@cornell.edu>
Date: Thu, 27 Oct 2011 08:11:39 -0400
From: Ken Brown <kbrown AT cornell DOT edu>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: gdb 7.3.50-2 crash
References: <4E9AB98E DOT 3020105 AT cornell DOT edu>
In-Reply-To: <4E9AB98E.3020105@cornell.edu>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

--------------090307020102010503040502
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

On 10/16/2011 7:01 AM, Ken Brown wrote:
> gdb 7.3.50-2 crashes with a segfault if a file is loaded and the
> following two command lines are sent:
>
> server interpreter mi "-file-list-exec-source-files"
> server list

I don't know if it helps, but I've modified the STC from 
http://cygwin.com/ml/cygwin/2011-10/msg00472.html to apply to the 
present problem.  I had to uncomment the sleep (1) to get it to run 
properly on my Linux system.  I also made the STC run "gdb --annotate=3" 
even though the crash occurs with just "gdb", because that's how gdb is 
run by emacs in the situation that led to this bug report.

The STC assumes that you have hello.exe in the current directory.

$ cat > hello.c << EOF
#include <stdio.h>

int
main ()
{
  printf("Hello, world!\n");
  return 0;
}
EOF

$ gcc -g -o hello hello.c

Ken

--------------090307020102010503040502
Content-Type: text/plain;
 name="gdbsegv.cc"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="gdbsegv.cc"

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pty.h>
#include <string.h>
#include <sys/wait.h>

void get_output (int fd);

int
main (int argc, const char **argv) 
{
  int master;
  pid_t pid;

  if ((pid = forkpty (&master, NULL, NULL, NULL)) < 0)
    {
      perror ("forkpty");
      exit (1);
    }
  /* child */
  if (pid == 0) 
    {
      const char *av[100];
      int i = 0;
#ifdef STRACE_GDB
      av[i++] = "strace";
      av[i++] = "-o";
      av[i++] = "/tmp/strace.out";
#ifdef __CYGWIN__
      av[i++] = "--mask=all+paranoid";
#endif
#endif
      av[i++] = argv[1] ?: "gdb";
      fprintf (stderr, "*** using %s\n", av[0]);
      av[i++] = "--annotate=3";
      av[i++] = "hello.exe";
      av[i] = NULL;
      execvp (av[0], (char * const *) av);
      /* shouldn't get here */
      exit (1);
    }
  /* parent */
  const char *input[20];

  int i = 0;
  input[i++] = "server interpreter mi \"-file-list-exec-source-files\"\n";
  input[i++] = "server list\n";
  input[i++] = "q\n";
  input[i] = NULL;

  for (int i = 0; input[i]; ++i)
    {
      write (master, input[i], strlen (input[i]));
      sleep (1);
    }
  get_output (master);
  wait (NULL);
}

void
get_output (int fd)
{
  char buf[4096];

  while (1)
    {
      int nread = read (fd, buf, sizeof (buf));
      if (nread > 0)
	write (STDOUT_FILENO, buf, nread);
      else
	{
	  printf ("No more output.  nread %d\n", nread);
	  break;
	}
    }
}




--------------090307020102010503040502
Content-Type: text/plain; charset=us-ascii

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
--------------090307020102010503040502--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019