Skip to content

MATLAB concore_read.m retry loop will hang forever and crashes on file errors, no try-catch, no max retries #239

@avinxshKD

Description

@avinxshKD

The retry loop in concore_read.m has two problems that'll bite you in any real MATLAB study:

  1. No error handling inside the retry loop

The first read attempt is wrapped in try-catch, which is fine. But the while loop that retries on empty content has bare fopen/fscanf/fclose calls with no protection:

while length(ins) == 0
    pause(concore.delay);
    input1 = fopen(strcat(concore.inpath,num2str(port),'/',name));
    ins = fscanf(input1,'%c');
    fclose(input1);
    concore.retrycount = concore.retrycount + 1;
end

If fopen fails here (returns -1), fscanf(-1, ...) throws an error and the whole function dies. The Python equivalent in both concore.py and concoredocker.py wraps retries in try-except — MATLAB should do the same.

  1. No max retry limit

The Python implementations cap retries at 5 (max_retries = 5). The MATLAB loop just goes while length(ins) == 0 with no upper bound. If the writing node crashes or the file stays empty for any reason, this spins forever and the study hangs with no feedback.

Both issues together mean that if anything goes wrong during a MATLAB node's read, you either get an unhandled crash or an infinite hang — neither gives you anything useful to debug.

Fix can be, wrap the loop body in try-catch (same as the initial read), add a max retry counter, and print a message when retries are exhausted so the user knows what happened.

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