Repeated Python calls of cyber_time.Time.now() results in a segmentation fault
Describe the bug
Repeated Python calls of cyber_time.Time.now() results in a segmentation fault. The error occurs after a finite number of calls determinable at runtime. The fault creates a core dump in data/core/. The cause may be a deallocation error in the Python cyber_time wrapper.
To Reproduce Steps to reproduce the behavior:
- Create a python script and import cyber_time:
from cyber_py import cyber_time - Make repeated calls to
cyber_time.Time.now().
The following script can reproduce the behavior:
from cyber_py import cyber_time
import time
while True:
time.sleep(0.001)
print(“cyber_time: “ + str(cyber_time.Time.now()))
The last lines of the output are something to the effect of:
…
cyber_time: 1557208426155302888
cyber_time: 1557208426156467792
cyber_time: 1557208426157638705
cyber_time: 1557208426158858018
cyber_time: 1557208426160047689
cyber_time: 1557208426161237213
cyber_time: 1557208426162425895
cyber_time: 1557208426163574659
cyber_time: 1557208426164752927
cyber_time: 1557208426165900939
cyber_time: 1557208426167094610
cyber_time: 1557208426168243628
cyber_time: 1557208426169396087
cyber_time: 1557208426170542029
Fatal Python error: deallocating None
Aborted (core dumped)
Expected behavior
The cyber_time.Time.now() as described should be used to provide timestamps for Cyber RT messages written via the cyber_py library and should not result in a segmentation fault despite repeated calls.
Screenshots
Screenshot 1:
An execution of the above script with python-dbg:

Desktop
- OS: Ubuntu 16.04
Additional context
The error occurs whether or not the suffix .to_sec() or .to_nsec() is included.
The while loop above can be modified to demonstrate the deallocation issue:
from cyber_py import cyber_time
import time
import sys
while True:
time.sleep(0.001)
print(“cyber_time: “ + str(cyber_time.Time.now()))
print(“refcount to None: “ + str(sys.getrefcount(None)))
@berthu Thank you for your question. We reviewed it as quickly as possible. The problem is caused by a reference count that has been fixed by commit #8215. Thanks again.
Closing this issue as it appears to be resolved. Feel free to reopen if you have additional questions. Thanks!