EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  <20202021  2022  2023  2024  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  <20202021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: [Merge] ~dirk.zimoch/epics-base:dbChannelForDBLinks into epics-base:7.0
From: Dirk Zimoch via Core-talk <core-talk at aps.anl.gov>
To: mp+378968 at code.launchpad.net
Date: Thu, 20 Feb 2020 13:26:21 -0000
The problem with db_create_read_log() is that it is not yet initialized when PINI=YES runs (resulting in a NULL pointer access crash). At least not in softIoc, in softIocPVA it works!

Diff comments:

> diff --git a/modules/database/src/ioc/db/dbDbLink.c b/modules/database/src/ioc/db/dbDbLink.c
> index f2cb0c5..ff77c3f 100644
> --- a/modules/database/src/ioc/db/dbDbLink.c
> +++ b/modules/database/src/ioc/db/dbDbLink.c
> @@ -160,30 +165,52 @@ static long dbDbGetValue(struct link *plink, short dbrType, void *pbuffer,
>          long *pnRequest)
>  {
>      struct pv_link *ppv_link = &plink->value.pv_link;
> -    DBADDR *paddr = ppv_link->pvt;
> +    dbChannel *chan = linkChannel(plink);
> +    DBADDR *paddr = &chan->addr;
>      dbCommon *precord = plink->precord;
>      long status;
>  
>      /* scan passive records if link is process passive  */
>      if (ppv_link->pvlMask & pvlOptPP) {
> -        status = dbScanPassive(precord, paddr->precord);
> +        status = dbScanPassive(precord, dbChannelRecord(chan));
>          if (status)
>              return status;
>      }
>  
> -    if (ppv_link->getCvt && ppv_link->lastGetdbrType == dbrType) {
> -        status = ppv_link->getCvt(paddr->pfield, pbuffer, paddr);
> +    /* If filters are involved in a read, create field log and run filters */
> +    if (ellCount(&chan->filters)) {
> +        long options = 0;
> +        db_field_log fl = {};
> +        fl.ctx = dbfl_context_read;
> +        fl.type = dbfl_type_rec;
> +
> +        /* For the moment, empty arrays are not supported by EPICS */
> +        if (dbChannelFinalElements(chan) > 0)
> +        {
> +            dbChannelRunPreChain(chan, &fl);
> +            dbChannelRunPostChain(chan, &fl);

I had that first but was running into other problems. So I changed it to a local variable after consulting Andrew.
I will change it back to a dynamically allocated object.

> +            status = dbChannelGet(chan, dbrType, pbuffer, &options, pnRequest, &fl);
> +            if (!status && pnRequest && *pnRequest <= 0)
> +                status = S_db_badField;
> +        } else {
> +            status = S_db_badField;
> +        }
> +        if (status) {
> +            recGblSetSevr(precord, LINK_ALARM, UDF_ALARM);
> +        }
> +    } else if (ppv_link->getCvt && ppv_link->lastGetdbrType == dbrType) {
> +        status = ppv_link->getCvt(dbChannelField(chan), pbuffer, paddr);
>      } else {
> -        unsigned short dbfType = paddr->field_type;
> +        unsigned short dbfType = dbChannelFinalFieldType(chan);
>  
>          if (dbrType < 0 || dbrType > DBR_ENUM || dbfType > DBF_DEVICE)
>              return S_db_badDbrtype;
>  
> -        if (paddr->no_elements == 1 && (!pnRequest || *pnRequest == 1)
> -                && paddr->special != SPC_DBADDR
> -                && paddr->special != SPC_ATTRIBUTE) {
> +        if (dbChannelFinalElements(chan) == 1 && (!pnRequest || *pnRequest == 1)
> +                && dbChannelSpecial(chan) != SPC_DBADDR
> +                && dbChannelSpecial(chan) != SPC_ATTRIBUTE) {
>              ppv_link->getCvt = dbFastGetConvertRoutine[dbfType][dbrType];
> -            status = ppv_link->getCvt(paddr->pfield, pbuffer, paddr);
> +            status = ppv_link->getCvt(dbChannelField(chan), pbuffer, paddr);
>          } else {
>              ppv_link->getCvt = NULL;
>              status = dbGet(paddr, dbrType, pbuffer, NULL, pnRequest, NULL);


-- 
https://code.launchpad.net/~dirk.zimoch/epics-base/+git/epics-base/+merge/378968
Your team EPICS Core Developers is subscribed to branch epics-base:7.0.

References:
[Merge] ~dirk.zimoch/epics-base:dbChannelForDBLinks into epics-base:7.0 Dirk Zimoch via Core-talk

Navigate by Date:
Prev: [Merge] ~dirk.zimoch/epics-base:emptyArrayCrashFix into epics-base:3.15 Dirk Zimoch via Core-talk
Next: Re: [Merge] ~dirk.zimoch/epics-base:dbChannelForDBLinks into epics-base:7.0 mdavidsaver via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  <20202021  2022  2023  2024 
Navigate by Thread:
Prev: Re: [Merge] ~dirk.zimoch/epics-base:dbChannelForDBLinks into epics-base:7.0 mdavidsaver via Core-talk
Next: Re: [Merge] ~dirk.zimoch/epics-base:dbChannelForDBLinks into epics-base:7.0 mdavidsaver via Core-talk
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  <20202021  2022  2023  2024 
ANJ, 20 Feb 2020 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·