Comment 4 for bug 1840500

Revision history for this message
Andrew Johnson (anj) wrote :

It looks like either an empty string or a too-long name were causing the SEGFAULT that the commit was protecting against — when a call to ca_create_channel() in tool_lib.c::create_pvs() fails and doesn't return a real chid, the caget() and cainfo() routines were still operating on the non-existent chid.

The pvs arrays in both programs are allocated using calloc() so this simple test for a NULL chid could be added to the cainfo() and caget() routines at the top of the for() loop to prevent a SEGFAULT:
    if (!pvs[n].chid) continue;
I would have made those changes myself just now if that was the only fix needed, but it isn't.

The connect_pvs() routine in tool_lib.c returns immediately without calling ca_pend_io() if its call to create_pvs() returned non-zero, so a bad PV name will still cause problems, preventing connections to other PVs on slower or remote IOCs. The create_pvs() routine is also called from camonitor.c so changing the semantics of its return value needs care to avoid breaking that.