Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

occasional segfault when reinitializing channel that is subscribed to class member function #96

Open
bsobhani opened this issue Nov 6, 2024 · 0 comments

Comments

@bsobhani
Copy link

bsobhani commented Nov 6, 2024

In the following script, when I set use_class_cb to 1, the script segfaults, but when I set use_class_cb to 0 it does not segfault:

import pvaccess
import time


def func_cb(rec):
        monitor.class_cb(rec)
        return


class Monitor:
        def __init__(self):
                self.channel = None
        def class_cb(self, rec):
                return

monitor = Monitor()
use_class_cb = 1
pvname = "nes:neutrons"
while True:
        if monitor.channel is not None:
                monitor.channel.stopMonitor()
        monitor.channel = pvaccess.Channel(pvname)
        if use_class_cb == 1:
                # segfaults sometimes
                monitor.channel.subscribe("monitor_cb", monitor.class_cb)
        else:
                # does not segfault
                monitor.channel.subscribe("monitor_cb", func_cb)
        monitor.channel.startMonitor()
        time.sleep(1)

Note: On my setup, nes:neutrons is a PV that updates frequently (multiple times per second). If I point to this PV it crashes within a few seconds. I tried pointing it to a PV that updates less frequently (once per second), and it took longer to crash (a little less than an hour).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant