Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

Re: gdb/2032: GDB introduces odd behavior with accept() function: msg#00060

gdb.bugs.discuss

Subject: Re: gdb/2032: GDB introduces odd behavior with accept() function

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>
Google Custom Search

Recently Viewed:
hardware.arm.at...    cms.citadel.dev...    video.gstreamer...    java.facelets.u...    misc.basics.qna...    web.wiki.instik...    network.uip.use...    xdg.devel/2003-...    tex.bibtex.bibd...    finance.quotesp...    ietf.zeroconf/2...    redhat.blinux.g...    suse.db2/2003-0...    php.phpesp/2004...    uml.devel/2003-...    gnome.labyrinth...    qnx.openqnx.dev...    boot-loaders.gr...    db.dataperfect....    audio.audacity....    linux.uclinux.m...    editors.j.devel...    os.openbsd.tech...    kde.users.multi...   
Home | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive 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

Navigation