Closed mliszcz closed 2 years ago
Thanks @mliszcz for the report. There is indeed something fishy in this part of the code. The attribute name reported in the exception is indeed wrong since att is pointing to the previous attribute in the given attribute list and att.get_name() is used in the exception. Your fix proposal (patch at the end of your issue description) seems quite natural to me. You are writing this is not fixing the crash. Did I understand well? att.name at least, should be fine with your version. The crash is quite strange. It seems to crash when destroying the DevFailed exception and when it is trying to deallocate the "API_PollObjNotFound" string (which is the reason field of the exception). I don't understand for the moment why there is a problem deallocating this string.
@bourtemb yes it is still crashing with the proposed patch. I did not spend much on investigating this. It stops crashing if I remove delete_seq
call. Maybe delete_seq
triggers some memory corruption which becomes visible during exception handling? Or maybe the issue is that this code is designed for Device and Device_2 while I am running it on Device_5.
I've found this suspicious piece of code during #511 investigation. Reference
att
is re-assigned which triggers (auto-generated) copy assignment operator (this is incorrect, as Attribute allocates and owns some pointers): https://github.com/tango-controls/cppTango/blob/4d2ad6555fd6bc6e6603406ea83b6ed0ed797eb3/cppapi/server/device.cpp#L2874-L2886I tried to trigger this code in a test (which may be wrong because it calls DeviceImpl method on Device_5Impl but I don't have any DeviceImpl available at the moment) :
When I'm trying to read "Short_attr" (which is VALID but has no value) an exception is reported for different attribute ("Long_attr") and is followed by a segmentation fault:
The test passes when I remove these two lines: https://github.com/tango-controls/cppTango/blob/4d2ad6555fd6bc6e6603406ea83b6ed0ed797eb3/cppapi/server/device.cpp#L2884-L2885
Reference corrections does not fix the crash: