EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: EPICS thread problem on cygwin-x86
From: Benjamin Franksen <[email protected]>
To: [email protected]
Date: Mon, 30 Apr 2007 10:35:07 +0200
On Friday 27 April 2007 21:37, Mark Rivers wrote:
> epics> threadTest 1
> Calling pthread_create
> pthread_create status=0
> Sleeping 5 seconds
> epics>
> epics>
> epics> threadTest 0
> Calling pthread_create
> pthread_create status=11
> pthread_create error Resource temporarily unavailable
> Segmentation fault (core dumped)
>
> So pthread_create is returning status=11 (EAGAIN) when things mess up.
> Any idea what this means and how to fix it?  And why is the error
> causing a seg fault, since it did simply return an error.

Hi Mark,

you probably know this but just in case: EAGAIN is the hallmark of 
cheap-and-dirty system design. In Unix, when a system call gets interrupted 
by a signal and must be restarted, the system doesn't automatically restart 
the call. Instead the system call returns the error code EAGAIN. Thus, in 
principle, every such call must be wrapped (by the user!) in a loop like 
this

do {
  ret = syscall(...);
} while (ret != EAGAIN);

How this relates to the concrete problem you are having I can't say, other 
than that it seems the reason in this case is not a signal but rather a 
'temporarily unavailable resource'.

BTW, since the status you get is not EPERM, the crash must happen some where 
inside the rest of the wrapper routine (the part which you did not quote), 
which is

static void * start_routine(void *arg)
{

	/*...error not in this part...*/

    if(status) {
        free_threadInfo(pthreadInfo);
        return 0;
    }
    status = pthread_sigmask(SIG_SETMASK,&oldSig,NULL);
    checkStatusOnce(status,"pthread_sigmask");
    return(pthreadInfo);
}

that is, either in free_threadInfo() or pthread_sigmask(). (I am assuming 
the crash really happens inside epicsThreadCreate().)

HTH
Ben

References:
RE: EPICS thread problem on cygwin-x86 Mark Rivers

Navigate by Date:
Prev: duplicate emails? Laznovsky, Michael
Next: RealPlayer complains of file not found for Getting Started with EPICS Lecture Series Dayle Kotturi
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: RE: EPICS thread problem on cygwin-x86 Mark Rivers
Next: [Fwd: New for Argonne National Laboratory Employees - Your Quarterly Newsletter from National Instruments] Ned D. Arnold
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  <20072008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 10 Nov 2011 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·