mdsplus icon indicating copy to clipboard operation
mdsplus copied to clipboard

MdsIpThreadStatic.c has an extraneous DEBUG define statement

Open mwinkel-dev opened this issue 1 year ago • 0 comments

Affiliation MIT PSFC

Version(s) Affected Recent "alpha", but likely in other versions too

Platform Ubuntu 20, but surely also on other platforms too

Describe the bug When running threaded applications, always receive debug messages similar to the following:

D, 1832925:1832943, 1698942711.128151250: <path>/mdsplus/mdstcpip/mdsipshr/MdsIpThreadStatic.c:48 buffer_free() Connection(id=2, state=0x80, protocol='tcp', info_name='tcp', version=3, user='(null)')

The message appears because there is a #define DEBUG statement in MdsIpThreadStatic.c of the mdsipshr library. line 39

Conjecture is that when work was done on mdsipshr threading, that the #define DEBUG was used for the initial debugging. And then either inadvertently left in the source code, or deliberately retained in order to generate debug messages for monitoring the performance of the threading.

To Reproduce Create a bug.py file that contains this Python code.

import MDSplus as mds
import concurrent.futures as cf

def get_data(path):
    return tree.getNode(path).getData().data()

# Main program -- bug not specific to this shot and signals
shot_num = 1090909009
paths = [
    "\CMOD::TOP.ENGINEERING.POWER_SYSTEM:TEST",
    "\CMOD::TOP.ENGINEERING.RGA_1:AFTER",
    "\CMOD::TOP.ENGINEERING.RGA_1:BEFORE",
    "\CMOD::TOP.SPECTROSCOPY.BOLOMETER:TWOPI_DIODE",
    "\CMOD::TOP.SPECTROSCOPY.BOLOMETER:TWOPI_FOIL"
]
tree = mds.Tree("cmod", shot_num, mode="readonly")

# Works with one thread, fails with multiple threads
with cf.ThreadPoolExecutor(max_workers=2) as executor:
    futures = [executor.submit(get_data, node_path) for node_path in paths]
    for future in cf.as_completed(futures):
        print(future.result())

Running the above bug.py produces the following output. Notice the D, 1832925: messages.

$ python3 bug.py      
Error in SendArg: mode = 6, status = 65554
Error in SendArg: mode = 6, status = 65554
Error in SendArg: mode = 6, status = 65554
D, 1832925:1832943, 1698942711.128151250: <path>/mdsplus/mdstcpip/mdsipshr/MdsIpThreadStatic.c:48 buffer_free() Connection(id=2, state=0x80, protocol='tcp', info_name='tcp', version=3, user='(null)')
D, 1832925:1832944, 1698942711.133187987: <path>/mdsplus/mdstcpip/mdsipshr/MdsIpThreadStatic.c:48 buffer_free() Connection(id=3, state=0x80, protocol='tcp', info_name='tcp', version=3, user='(null)')
Traceback (most recent call last):

Expected behavior No debug messages when in a "release" build.

Screenshots n/a

Additional context Thanks to Josh L. of the MIT PSFC Disruptions Team for reporting this bug.

mwinkel-dev avatar Nov 02 '23 18:11 mwinkel-dev