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  <20202021  2022  2023  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  <20202021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: String size limit for Eiger FileWriter when compiling with g++ > 5.2
From: Bruno Martins via Tech-talk <tech-talk at aps.anl.gov>
To: "Wlodek, Jakub" <jwlodek at bnl.gov>
Cc: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Wed, 4 Mar 2020 13:22:14 -0500
OR put the string on the heap

Bruno


On Wed, Mar 4, 2020 at 1:19 PM Bruno Martins <brunoseivam at gmail.com> wrote:
I believe memcpy'ing a std::string might not be safe. My theory is that std::string internals changed: the underlying data is probably being automatically deallocated between sending a string on one end and getting it on the other end of a queue, since we're essentially copying bytes. It might not happen for smaller strings because their content is probably inlined in the std::string type itself.

Maybe that was always the behavior, but the inlining length threshold is the thing that changed.

The way I see it, you have to either keep the change you mentioned OR use a different queue that's aware of the data type it is transporting, taking ownership of the queue items (which, AFAIK, EPICS doesn't provide).

Bruno


On Wed, Mar 4, 2020 at 12:12 PM Wlodek, Jakub via Tech-talk <tech-talk at aps.anl.gov> wrote:
Hello all,

I have an interesting issue that I wanted to get some feedback on. One of our beamlines is running several Eiger detectors that were recently moved to a Debian 9 system,
and as soon as they were moved, we recieved feedback that the FileWriter was not saving the h5 files to the local storage.

After some testing, this was confirmed, however, only when the FilePattern PV was longer than 15 characters. The h5 file would be saved to the Eiger server and was visible
through the web interface, but was not copied to the local storage. Seeing as 15 characters was the limit, and the call sizeof(std::string) would return 15 with g++ > 5.2, we figured
out that somewhere there was an issue stemming from this, especially since on Debian 7 (g++ version 4.7.2) we did not see the problem.

I found that the following structure is sent on a message queue: epicsMessageQueue mPollQueue:

typedef struct
{
  string pattern;
    int sequenceId;
    size_t nDataFiles;
     bool saveFiles, parseFiles, removeFiles;
     mode_t filePerms;
}acquisition_t;

And calling pattern.c_str() before it was sent on the queue would print the full value, but on the recieve pattern.c_str() would be empty whenever the string
was longer than 15 characters. The queue was initialized with:

mPollQueue(1, sizeof(acquisition_t)),

My first idea was to simply increase the size of this second parameter for the epicsMessageQueue, but that did not solve the problem.

What did was changing the string pattern to char pattern[MAX_BUF_SIZE], and ensure that any time this pattern variable was called a conversion from string
to char[] was done.

My question is, is there a better way to fix this where the driver can continue to use std::string? And why did increasing the max transport size for the queue not
also fix the issue?

Regards,
Jakub

References:
String size limit for Eiger FileWriter when compiling with g++ > 5.2 Wlodek, Jakub via Tech-talk
Re: String size limit for Eiger FileWriter when compiling with g++ > 5.2 Bruno Martins via Tech-talk

Navigate by Date:
Prev: Re: String size limit for Eiger FileWriter when compiling with g++ > 5.2 Bruno Martins via Tech-talk
Next: Re: String size limit for Eiger FileWriter when compiling with g++ > 5.2 Wlodek, Jakub 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  <20202021  2022  2023  2024 
Navigate by Thread:
Prev: Re: String size limit for Eiger FileWriter when compiling with g++ > 5.2 Bruno Martins via Tech-talk
Next: Re: String size limit for Eiger FileWriter when compiling with g++ > 5.2 Wlodek, Jakub 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  <20202021  2022  2023  2024 
ANJ, 04 Mar 2020 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·