pylogix: Random segmentation fault (core dumped) in ARM64
Hi
My program Read tag values in a loop, 1 time/second.
This program running in Docker (base image is Python 3.7.4), on ARM64 platform. I have test many times, this Segmentation fault (core dumped) happen randomly.
pylogix==0.6.4 and 0.7.7 both have this problem.
my code is like this.
def rockwellread(rockwellip):
comm = PLC()
comm.IPAddress=rockwellip
for i in range(len(taglist)):
tagValue[i] = (comm.Read(taglist[i])).Value
# tagValue[i] = random.random()
return tagValue
while 1:
rockwellread(rockwellip)
time.sleep(1)
For this code, random.random() won’t Segmentation fault (core dumped), once I use comm.Read this happen randomly, Maybe after loops for dozens time or hundreds times.
I am not familiar with C/C++, and don’t know how to solve this. Please help.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 38 (10 by maintainers)
I have tested on Raspberry Pi 3B, armv7l, nothing goes wrong, both in Docker and outside Docker. I’ll close this issue. Thank you all.
I pushed a commit that should take care of this BOOL array in list issue.
@dmroeder did a bit of troubleshooting this morning, I can confirm latest 0.7.7 there’s a bug for boolean list read. #154 will def prevent this in the future as far as testing goes.
However the same test passes fine in 0.7.5:
Happy new year!
@dmroeder @TheFern2
I found this issue, https://github.com/python-pillow/Pillow/issues/1935 maybe we can get something from it, something about docker container privileged or stack size control.
Sorry, I mistouch the close button on my phone.
Yes, we are doing the something as you said, and need time.
@TheFern2 you are right, there are two problems going on here. Reading and the segmentation fault.
Segmentation fault suggests that the python interpreter crashed. From my experience, this happens when a program which binds to some other language crashes. For example, OpenCV, where they have a python layer that binds to C. I don’t believe pylogix is causing the segmentation fault, something else is crashing.
Sleep is in seconds. 0.2 seconds = 200ms. 0.02 seconds = 20ms
pylogix is a pure python project. Full stack trace might be helpful as @TheFern2 points out.
One problem I see with your example, each time you are calling rockwellread(), you are creating a new instance of the driver while not closing it. The PLC will eventually flush the connections, but you are creating new connections faster than the PLC will flush them, it will eventually get tired of this.
Why read each tag individually and not just just read the whole list at once? It would be much faster to read the list.
Maybe the segfault comes from the IP stack? Since your code is running the read in a tight loop you may be overwhelming the device you are talking to. If this happens it might send garbage back.
Put something like time.sleep(0.020) in your loop and see if this prevents the segfault.