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: asynDriver, problem with asynInt32Array read routine
From: "Mark Rivers" <[email protected]>
To: "Janez Golob" <[email protected]>, <[email protected]>
Date: Fri, 23 Feb 2007 11:54:51 -0600
Hi Janez,
 
I think your problem probably does not have to do directly with asyn, but rather is something with the waveform record.  The error you are getting:

> When I run episc database in which I have some ai record type everything working fine but when I add waveform record type I get following error:

> fatal error: dbScanLock. Bad case choice.

Here is the code in EPICS base (dbLock.c) that is generating that error:

    while(1) {
        epicsMutexMustLock(lockSetModifyLock);
        plockSet = plockRecord->plockSet;
        if(!plockSet) goto getGlobalLock;
        switch(plockSet->state) {
            case lockSetStateFree:
                status = epicsMutexTryLock(plockSet->lock);
                assert(status==epicsMutexLockOK);
                plockSet->nRecursion = 1;
                plockSet->thread_id = idSelf;
                plockSet->precord = precord;
                plockSet->state = lockSetStateScanLock;
                epicsMutexUnlock(lockSetModifyLock);
                return;
            case lockSetStateScanLock:
                if(plockSet->thread_id!=idSelf) {
                    plockSet->nWaiting +=1;
                    epicsMutexUnlock(lockSetModifyLock);
                    epicsMutexMustLock(plockSet->lock);
                    epicsMutexMustLock(lockSetModifyLock);
                    plockSet->nWaiting -=1;
                    if(plockSet->state==lockSetStateRecordLock) {
                       epicsMutexUnlock(plockSet->lock);
                       goto getGlobalLock;
                    }
                    assert(plockSet->state==lockSetStateScanLock);
                    plockSet->nRecursion = 1;
                    plockSet->thread_id = idSelf;
                    plockSet->precord = precord;
                } else {
                    plockSet->nRecursion += 1;
                }
                epicsMutexUnlock(lockSetModifyLock);
                return;
            case lockSetStateRecordLock:
                /*Only recursive locking is permitted*/
                if((plockSet->nRecursion==0) || (plockSet->thread_id!=idSelf))
                    goto getGlobalLock;
                plockSet->nRecursion += 1;
                epicsMutexUnlock(lockSetModifyLock);
                return;
            default:
                cantProceed("dbScanLock. Bad case choice");
        }

So for some reason pLockSet->state has an invalid value.  I suspect there is a memory corruption problem, perhaps the waveform record support is going beyond array bounds?

Mark


From: Janez Golob [mailto:[email protected]]
Sent: Thursday, February 22, 2007 1:26 PM
To: [email protected]
Subject: asynDriver, problem with asynInt32Array read routine

Hello,

I am writing portDriver for aio card. I read some data from asynInt32 and asynInt32Array interface type:

static asynInt32 drvAio16Int32 = {

NULL,

readInt32,

getBounds,

NULL,

NULL

};

static asynInt32Array drvAio16Int32Array = {

NULL,

readInt32Array,

NULL,

NULL

};

...

Ok interfaces inicialization and ....

...

pPvt->common.interfaceType = asynCommonType;

pPvt->common.pinterface = (void *)&aio16Common;

pPvt->common.drvPvt = pPvt;

pPvt->int32.interfaceType = asynInt32Type;

pPvt->int32.pinterface = (void *)&drvAio16Int32;

pPvt->int32.drvPvt = pPvt;

pPvt->int32Array.interfaceType = asynInt32ArrayType;

pPvt->int32Array.pinterface = (void *)&drvAio16Int32Array;

pPvt->int32Array.drvPvt = pPvt;

...

And asynInt32Array adn asynInt32 read methods are as follows

...

static asynStatus readInt32( void *drvPvt, asynUser *pasynUser, epicsInt32 *value )

{

drvAio16Pvt *pPvt = (drvAio16Pvt *)drvPvt;

rtems_unsigned8 channel;

rtems_unsigned16 data, size;

pasynManager->getAddr(pasynUser, &channel);

....

some code (calculating...)

....

*value = ( epicsInt32 )data_buffer[0];

asynPrint(pasynUser, ASYN_TRACEIO_DRIVER,

"drvAio16, port %s, read %d from channel %d\n",

pPvt->port_name, *value, channel);

return asynSucces;

}

/* Asyn Waveform read routine */

static asynStatus readInt32Array(void *drvPvt, asynUser *pasynUser, epicsInt32 *value, size_t nelements, size_t *nIn)

{

drvAio16Pvt *pPvt = (drvAio16Pvt *)drvPvt;

rtems_unsigned32 read_samples, i;

pasynManager->getAddr(pasynUser, &channel);

....

some code (calculating...)

....

return asynSucces;

}

When I run episc database in which I have some ai record type everything working fine but when I add waveform record type I get following error:

fatal error: dbScanLock. Bad case choice.

So what it's different between asynInt32 and asynInt32array read routine? Why asynInt32 read routine work but asynInt32Array read routine crash?

Episc version: 3.14.8.2

Asyn version: 4.3

Build target RTEMS-pc386

Thanks in advance!


Navigate by Date:
Prev: Re: Anyone using RSS/Atom? Noboru Yamamoto
Next: RE: Java IDE & graphic library Chu, Chungming Paul
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: asynDriver, problem with asynInt32Array read routine Janez Golob
Next: Orderly IOC shutdown? Michael Abbott
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 ·