gdb  User: guest  Access: viewconf gnatsweb
MAIN PAGECREATEQUERYADV. QUERYLOGIN AGAINHELP

View Problem Report: 259

or add note or send email to interested parties


Reporter's email: lkiss@deltaprime.com
CC these people
on PR status email:
   
Number: 259
Category: threads
Synopsis: Thread receives Interrupted System Call error while waiting on message queue.
Confidential: no
Severity: serious
Priority: medium
Responsible: chastain
State: closed
Class: sw-bug
Submitter-Id: net
Arrival-Date: Fri Dec 14 09:58:01 PST 2001
Closed-Date: Wed Nov 26 23:41:03 UTC 2003
Last-Modified: Wed Nov 26 23:41:03 UTC 2003
Originator: Laszlo Kiss
Release: gdb-5.1-1
Organization:
Environment: Red Hat 7.2
All updates applied as of 12/12/01.
Description: If a thread is waiting on a message queue and another thread
is created (say in the main thread) the msgrcv() function
returns with an error code of EINTR.

This appears to be the case only while the program is under
gdb's control.
File Attachments:
download filename size
qtest.c 3k
How-To-Repeat: Compile enclosed file with:
cc -g -Wall -Wno-unused -o qtest qtest.c -lpthread

Run from command line.
Run from within gdb.
Fix:
Release-Note:
Unformatted:

or send email to interested parties

Audit Trail:

From: Daniel Jacobowitz <drow@mvista.com>
To: lkiss@deltaprime.com
Cc: gdb-gnats@sources.redhat.com
Subject: Re: gdb/259: Thread receives Interrupted System Call error while waiting on message queue.
Date: Fri, 14 Dec 2001 20:38:20 -0500

 On Fri, Dec 14, 2001 at 05:48:29PM -0000, lkiss@deltaprime.com wrote:
 > If a thread is waiting on a message queue and another thread
 > is created (say in the main thread) the msgrcv() function
 > returns with an error code of EINTR.
 > 
 > This appears to be the case only while the program is under
 > gdb's control.
 
 That's right.  When a new thread is created, all threads running under
 GDB will receive a signal.  This is a fairly legitimate thing to do. 
 In an ideal world, the application would never find out; but in all
 current versions of Linux, they do.  This may be fixed in the kernel
 sometime soon.
 
 -- 
 Daniel Jacobowitz                           Carnegie Mellon University
 MontaVista Software                         Debian GNU/Linux Developer
Responsible-Changed-From-To: unassigned->chastain
Responsible-Changed-By: chastain
Responsible-Changed-When: Mon Sep 22 21:48:21 2003
Responsible-Changed-Why:
    
    Hello,
    
    I have a similar isse with 'sleep' returning early when pthread_create is invoked elsewhere in the process.
    
    As Daniel Jacobowitz says, it's legitimate for most system calls to return on receipt of a signal.  It's unfortunate that gdb+pthreads introduces more signals into the program, but it is legal for a system call to return early on receipt of a signal.  The moral is: always check the return value from a system call.
    
    I'm planning to document this in the gdb threads section of the manual, so that people will at least know what gdb is doing.
    
    Michael C
    GDB QA Guy
State-Changed-From-To: open->closed
State-Changed-By: chastain
State-Changed-When: Wed Nov 26 23:41:03 2003
State-Changed-Why:
    Hello,
    
    Thanks for your gdb bug report from 2001-12-14.
    
    Your analysis in the description is correct.  When a program is run under gdb, and the program creates or destroys a thread, and another thread in the program is inside a system call, the system call may return with -EINTR.
    
    That's because gdb puts hidden breakpoints on certain functions like thread creation so that it can track these events.  The same thing happens with user breakpoints, but it's more nasty to the gdb user when it happens with an internal implementation breakpoint.
    
    The next version of gdb will have a section in the manual documenting this limitation.  It's in the index under "thread breakpoints and system calls".
    
    You can wrap your system calls in loops that check for -EINTR and retry the system call.
    
    Michael C
    GDB QA Guy