I've been able to reproduce reliably a segfault that started to appear after our tango 9 migration. It turns out that pushing a change event with an invalid quality from the code can cause the device server to segfault (not everytime though). Here is the server code I used to reproduce the issue:
import time from tango.server import Device, DeviceMeta, command, attribute from tango import DevState, AttrQuality class SegfaultTest(Device): __metaclass__ = DeviceMeta def init_device(self): self.set_change_event('value', True, False) self.set_state(DevState.ON) @command def push_invalid(self): print('pushing invalid...') self.push_change_event( 'value', 0.0, time.time(), AttrQuality.ATTR_INVALID) print('pushed!') @attribute def value(self): return -1 if __name__ == '__main__': SegfaultTest.run_server()
And the client code:
import tango.utils from time import sleep def test(): cb = tango.utils.EventCallBack() proxy = tango.DeviceProxy('test/vinmic/segfault') eid = proxy.subscribe_event('value', tango.EventType.CHANGE_EVENT, cb) proxy.push_invalid() proxy.unsubscribe_event(eid) while True: test() sleep(0.5)
I've also been able to reproduce the segfault with a C++ device server, though it might take longer for the server to crash (the python version usually crashes at the first iteration of the client script). I'm using tango 9.2.2 with patch 922_1.
Let me know if you need more information,
Thanks
/Vincent
Here's the back trace (same for python and C++ devices):
I have compared the relevant code to version 8.1.2. There has been some refactoring there. In Tango 8, DeviceImpl::data_into_net_object is not called from Attribute::Attribute_2_AttributeValue if the quality is ATTR_INVALID.
Something like this seems to solve the problem:
Bug fixed in SVN.
Andreas: thank's for the bug fix but note that I had also to add another small change due to this bug
in file server/zmqeventsupplier.cpp. This is also in SVN for the same commit
Cheers
Emmanuel