push_archive_event() or push_change_event() methods causing a crash in some specific situations
We have observed some device servers crashes when DeviceImpl::push_archive_event() or Device::Impl::push_change_event() methods are invoked in some specific situations.
For instance when these methods are invoked after having invoked attr.set_value() inside a read_MyAttributeName(Tango::Attribute &attr) method. Here is a code example for an attribute named Value:
void TestArchive::read_Value(Tango::Attribute &attr)
{
DEBUG_STREAM << "TestArchive::read_Value(Tango::Attribute &attr) entering... " << endl;
/*----- PROTECTED REGION ID(TestArchive::read_Value) ENABLED START -----*/
Tango::DevLong64 x = 0x5555333377771111;
*attr_Value_read = x;
// No problem when push_<archive|change>_event is invoked before attr.set_value()
//push_archive_event(attr.get_name(), &x);
// Set the attribute value
attr.set_value(attr_Value_read);
push_archive_event(attr.get_name(),&x); // A crash will occur after exiting TestArchive::read_Value
/*----- PROTECTED REGION END -----*/ // TestArchive::read_Value
}
A similar problem could arise when reading an attribute X is triggering push_archive_event() or push_change_event() on another attribute Y and if these 2 attributes are read together in the same read_attributes(). In this particular case, a crash will occur only if Y is read before X. This case may happen in Tango 9 when the 2 attributes are polled at the same polling period, since Tango 9 is using read_attributes() by default to read all the attributes configured with the same polling period.