Skip to content

Variable used before assignment can lead to silent data corruption #18

@subhk

Description

@subhk

File: preprocessing/preprocessing.py:106, 137

The variable mask is only assigned within the elif estimate_bot branch (line 106). When bottom_depth exists in the dataset (line 88), execution takes the if branch, and the mask is never assigned. However, line 137 unconditionally executes np.save(mask_file, mask).

If processing multiple frequencies in the loop, the mask may persist from a previous iteration, resulting in a mask from frequency A being saved alongside the image from frequency B. This is silent data corruption — downstream analyses would operate on mismatched image/mask pairs with no indication of error. If it is the first frequency, this raises a NameError that aborts processing.

Ref: openjournals/joss-reviews#9240

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions