EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

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

Subject: Re: Possible bug??? in dbReadDatabaseFP
From: Michael Davidsaver via Tech-talk <tech-talk at aps.anl.gov>
To: "Dudley, David" <dudleyd at frib.msu.edu>, Andrew Johnson <anj at aps.anl.gov>
Cc: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Thu, 3 Mar 2022 08:47:59 -0800
On 3/3/22 08:16, Dudley, David via Tech-talk wrote:
If I do define ‘USE_TMPFILE’ (which was my original idea), it creates the temporary file, writes a proper record to it (I have checked this), and then calls ‘dbReadDatabaseFP’.

In this case, the IOC shows that it loaded the database, closed the file, and then I get a ‘free(): double free detected in tcache 2’ error and the IOC aborts.


It looks like dbReadDatabaseFP() will close the provided 'FILE*' on success,
and sometimes on failure[1].

So your code should not call fclose() after dbReadDatabaseFP().

eg.

https://github.com/mdavidsaver/pyDevSup/blob/ea5f0d62412085dfc941e8fe758695abdfdab548/devsupApp/src/dbapi.c#L219-L221

It may be worth noting that pyDevSup is the only usage of dbReadDatabaseFP()
I could find, and I doubt this aspect has had much testing.


fyi.  If you only need Linux support, you might look into fmemopen()

https://man7.org/linux/man-pages/man3/fmemopen.3.html


@Andrew

[1] Should the first error check should be changed to set 'status' and
    'goto cleanup' instead of returning immediately?

https://github.com/epics-base/epics-base/blob/d8c537945354f13433c685b5a6c6a30bc6dc6848/modules/database/src/ioc/dbStatic/dbLexRoutines.c#L226-L227

References:
Possible bug??? in dbReadDatabaseFP Dudley, David via Tech-talk

Navigate by Date:
Prev: Re: Timing in seq record Andrew Johnson via Tech-talk
Next: strange error Pop up error in win10 epics 网易邮件中心 via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  <20222023  2024 
Navigate by Thread:
Prev: Possible bug??? in dbReadDatabaseFP Dudley, David via Tech-talk
Next: strange error Pop up error in win10 epics 网易邮件中心 via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  <20222023  2024 
ANJ, 14 Sep 2022 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·