Skip to content

crash in 8.0.0-alpha1 when using >49 Zernike terms #250

@atsju

Description

@atsju

This comes from #246. I just move it here as it's a different issue and 246 will get closed by #247

#246 (comment)

7.4 is fine for now. Wait until you are back. I found another bug but unrelated to the crash and possibly not a new bug.

If you have a wavefront loaded, then go to "tools" "edit zernike values", then check the first zernike term (critical for graph to work well) and then check any value after 49 and put in a value of 1 and then click "create wavefront", the lastest code will crash as expected.

Version 7.4 doesn't crash for me (but it should I think?) and it doesn't seem to do anything with the zernike's above 49. Here's the line of code that caught my attention:

DFTFringe/zernikeeditdlg.cpp

Line 68 in c6ec43f

zernikePolar zpolar(rho, theta, tableModel->rowCount());
The 3rd parameter is 81 by default. This definitely causes an error in v8.0.0 in zernikePolar (it prints a warning and then when you go to use the array, values > 49 will crash).

I'm not sure what this code did in 7.4 and older if you tried to do zerniike's > 49. I'd like you to look at that Julien.

I'm doing other stuff now but I might put in some logging to locate the bug. Will be a pain (waiting for github to build) but I might do it anyway.

So I've narrowed the crash down to a few lines of code:

file >> width;
file >> height;
cv::Mat data(height,width, numType,0.);
spdlog::get("logger")->trace("readWaveFront() width {} height {}", width, height);

for( size_t y = 0; y < height; y++ ) {
    for( size_t x = 0; x < width; x++ ) {
        file >> data.at<double>(height - y-1,x);
        //data.at<double>(height - y - 1, x) += dist(generator);
    }
}
spdlog::get("logger")->trace("readWaveFront() step 2");

It gets toe the first log command and logs this:
[2025-10-04 14:57:43.735] [trace] readWaveFront() width 640 height 640

And that's the last thing logged before crashing. It crashes when loading the first of 4 files to analyze for purposes of the test stand astig removal tool.

However, the strange thing, is that if I click "load wavefront" and load the exact same wavefront, it does not crash and runs right through just fine. In fact I loaded all 4 wavefronts to be sure.

Anyway, could the somehow be related to windows file handling which is typically either binary or text mode where in text mode it messes around with the line endings and in binary mode you see the actual bytes including carriage return and also linefeed?

I think I'll stop here and let Julien look at this in a week or so.

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