Skip to content

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

@bsobhani

Description

@bsobhani

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions