|
|
Choosing A Webhost: |
Re: gdb/2032: GDB introduces odd behavior with accept() function: msg#00060gdb.bugs.discuss
The following reply was made to PR gdb/2032; it has been noted by GNATS. From: Daniel Jacobowitz <drow@xxxxxxxxx> To: devin@xxxxxxxxxxxxx, kettenis@xxxxxxx Cc: gdb-gnats@xxxxxxxxxxxxxxxxxx Subject: Re: gdb/2032: GDB introduces odd behavior with accept() function Date: Fri, 11 Nov 2005 22:57:38 -0500 [on i386, probably other places too] Mark, you wrote some of this code, so I wanted to run this by you. On Fri, Nov 11, 2005 at 11:30:37PM -0000, devin@xxxxxxxxxxxxx wrote: > When debugging this test program, interupt it during the accept and > type "signal SIGHUP". fd becomes -512. Without using gdb, it > becomes -1. The -512 is ERESTARTNOHAND, or one of the other internal error codes. It escapes because GDB has cancelled the syscall restart. Two issues here: - We don't need to cancel the syscall restart in this case. If the target is being resumed at the same PC, whether or not a new signal is being delivered, there's no reason not to let the syscall restart. Can we conditionalize this on writing a _different_ PC? - The reason the -512 escapes is that we've cancelled syscall restarting, but not fixed up errno. The Linux kernel always fixes the register value for errno when handling syscall restart; I think it's reasonable for GDB to do the same thing if orig_eax >= 0. Yes, this is a bit of linux-kernel-internals leaking to userspace, but that's what we get for being so tricksy... I think either fix would be ok separately, or both together. If we're changing the PC, probably wherever we're changing it to doesn't care what's in %eax right now, so we don't need to clear it. If we're leaving the PC alone, and we do want to cancel the syscall, we'll have to frob errno back to EINTR ourselves. Make some sense? > #define _XOPEN_SOURCE 600 > #include <sys/socket.h> > #include <sys/types.h> > #include <arpa/inet.h> > #include <stdio.h> > #include <signal.h> > > void hangup(int sig) { fprintf(stderr, "SIG=%i\n", sig); } > > int main(void) > { > int sockfd = socket(AF_INET, SOCK_STREAM, 0); > struct sockaddr_in addr = {0}; > int len = sizeof(addr); > > addr.sin_family = AF_INET; > addr.sin_port = htons(9999); > bind(sockfd, &addr, len); > listen(sockfd,5); > > signal(SIGHUP, hangup); > > int fd; > while(fd = accept(sockfd, &addr, &len)) > fprintf(stderr, "FD=%i\n", fd); > > } > >How-To-Repeat: > > >Fix: > > >Release-Note: > >Audit-Trail: > >Unformatted: > -- Daniel Jacobowitz CodeSourcery, LLC
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: gdb/2032: GDB introduces odd behavior with accept() function, mal0rd |
|---|---|
| Next by Date: | Re: backtrace/2024: backtrace fails when function ends with call to abort, drow |
| Previous by Thread: | Re: gdb/2032: GDB introduces odd behavior with accept() function, mal0rd |
| Next by Thread: | testsuite/2033: sigbpt.exp fails on Solaris10 and Solaris9 (possibly others), steve |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
Free MagazinesCisco NewsReceive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business. subscribe Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field. subscribe The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business. subscribe Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company. subscribe Total Telecom Total Telecom is "The Economist of the communications industry". subscribe |