{"action":"created","issue":{"url":"https://api.github.com/repos/tango-controls/pytango/issues/147","repository_url":"https://api.github.com/repos/tango-controls/pytango","labels_url":"https://api.github.com/repos/tango-controls/pytango/issues/147/labels{/name}","comments_url":"https://api.github.com/repos/tango-controls/pytango/issues/147/comments","events_url":"https://api.github.com/repos/tango-controls/pytango/issues/147/events","html_url":"https://github.com/tango-controls/pytango/issues/147","id":245751543,"number":147,"title":"simultaneous events corrupt event_data","user":{"login":"jkotan","id":10651163,"avatar_url":"https://avatars0.githubusercontent.com/u/10651163?v=4","gravatar_id":"","url":"https://api.github.com/users/jkotan","html_url":"https://github.com/jkotan","followers_url":"https://api.github.com/users/jkotan/followers","following_url":"https://api.github.com/users/jkotan/following{/other_user}","gists_url":"https://api.github.com/users/jkotan/gists{/gist_id}","starred_url":"https://api.github.com/users/jkotan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkotan/subscriptions","organizations_url":"https://api.github.com/users/jkotan/orgs","repos_url":"https://api.github.com/users/jkotan/repos","events_url":"https://api.github.com/users/jkotan/events{/privacy}","received_events_url":"https://api.github.com/users/jkotan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2017-07-26T14:58:49Z","updated_at":"2017-07-27T10:45:45Z","closed_at":null,"body":"Hi,\r\n\r\nduring my stress tests with sardana  https://github.com/sardana-org/sardana/issues/447\r\nI found that when I emits EventType.CHANGE_EVENT events of DevEncoded attribute:\r\n\r\n    import PyTango\r\n    from taurus.core.util.codecs import CodecFactory\r\n    \r\n    def cb(event_data):\r\n        if event_data.err:\r\n            print \"event error\"\r\n            return\r\n        w = CodecFactory().decode(event_data.attr_value.value)\r\n\r\n    door = PyTango.DeviceProxy(\"door/stretch-jk/1\")\r\n\r\n    while True:\r\n        id_ = door.subscribe_event(\"RecordData\", PyTango.EventType.CHANGE_EVENT, cb, stateless=True)\r\n        door.unsubscribe_event(id_)\r\n\r\n\r\nfor a very few  cases `event_data` is changed by `pytango/tango`. \r\nI run test with PyTango 9.2.1  and 9.2.0 (tango 8.2.5a)  on stretch and jessie getting similar issues.\r\nI've not manged to check it with the develop branch of  PyTango because of  https://github.com/tango-controls/pytango/issues/144\r\nError appears when I run simultaneously many clients subscribed to the same attribute. \r\n\r\n\r\nIn order to check it  I added print-outs in\r\n1)  `void __set_value(...)` in `val_real` of `ext/server/attribute.cpp` indirectly called by `read_RecordData` \r\n2)  `update_value_as_string<Tango::DEV_ENCODED>(...)` in `r_ch_ptr` of `ext/device_attribute.cpp` called during creating event_data which is read by callback method.\r\n\r\nIn the most cases for the corresponding calls the data were equal but I get also cases where\r\na few bytes  of long encoded data records of  `r_ch_ptr` were overwritten at the end or at the begining e.g.\r\na)\r\n\r\n    val_real[-10:] =  '\\xdc\\x91N\\x14$\\x11=\\x914\\x00'\r\n    r_ch_ptr[-10:] =  '\\xdc\\x91N\\x90-\\x00\\x00\\x00\\x00\\x00'\r\n\r\nb)\r\n\r\n    val_real[-10:] =  '\\xb9\"\\x9c(H&C\\xf0\\x89\\x80'\r\n    r_ch_ptr[-10:] =  '\\xb9\"\\x9c(H&C\\x80-\\x00'\r\n\r\nc) \r\n \r\n    val_real[:20] = 'BZh91AY&SYy\\x18\\x1ci\\x00C\\xc8\\x7f\\xff\\xff'\r\n    r_ch_ptr[:20] = '\\xce\\x03\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x1ci\\x00C\\xc8\\x7f\\xff\\xff'\r\n\r\nFor 9.2.0 I get also the cases where whole long data_event value was filled with '\\x00' characters.\r\nIn my test case since the data is pickled during decoding data I get `IOError: invalid data stream` but I can imaging that for other cases user may even not notice that the data is corrupted.\r\n\r\nTherefore I would like to ask if someone account  a similar problem.\r\n\r\nBest regards,\r\nJan\r\n\r\n\r\n\r\n    "},"comment":{"url":"https://api.github.com/repos/tango-controls/pytango/issues/comments/318327155","html_url":"https://github.com/tango-controls/pytango/issues/147#issuecomment-318327155","issue_url":"https://api.github.com/repos/tango-controls/pytango/issues/147","id":318327155,"user":{"login":"vxgmichel","id":7490006,"avatar_url":"https://avatars1.githubusercontent.com/u/7490006?v=4","gravatar_id":"","url":"https://api.github.com/users/vxgmichel","html_url":"https://github.com/vxgmichel","followers_url":"https://api.github.com/users/vxgmichel/followers","following_url":"https://api.github.com/users/vxgmichel/following{/other_user}","gists_url":"https://api.github.com/users/vxgmichel/gists{/gist_id}","starred_url":"https://api.github.com/users/vxgmichel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vxgmichel/subscriptions","organizations_url":"https://api.github.com/users/vxgmichel/orgs","repos_url":"https://api.github.com/users/vxgmichel/repos","events_url":"https://api.github.com/users/vxgmichel/events{/privacy}","received_events_url":"https://api.github.com/users/vxgmichel/received_events","type":"User","site_admin":false},"created_at":"2017-07-27T10:45:45Z","updated_at":"2017-07-27T10:45:45Z","body":"Thank you for the report, I found the problem: 71236c9d\r\n\r\nI'm working on a fix now."}}
{"actor":{"display_login":"vxgmichel"}}