Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LinearInterpolation can access out of bounds with NaN input #30157

Open
joshuahansel opened this issue Mar 20, 2025 · 0 comments · May be fixed by #30159
Open

LinearInterpolation can access out of bounds with NaN input #30157

joshuahansel opened this issue Mar 20, 2025 · 0 comments · May be fixed by #30159
Assignees
Labels
C: Framework P: normal A defect affecting operation with a low possibility of significantly affects. T: defect An anomaly, which is anything that deviates from expectations.

Comments

@joshuahansel
Copy link
Contributor

Bug Description

In LinearInterpolation, if you do sample(x) and x is a NaN, then it will try and access out of bounds in this:

  auto upper = std::upper_bound(_x.begin(), _x.end(), x);
  int i = std::distance(_x.begin(), upper) - 1;
  return _y[i] + (_y[i + 1] - _y[i]) * (x - _x[i]) / (_x[i + 1] - _x[i]);

If no upper bound exists for x (as in the case of nan), upper = _x.end() and then i = _x.size() - 1, which is a problem for y[i + 1].

Steps to Reproduce

See above.

Impact

Garbage results if nan values are input to object.

[Optional] Diagnostics

No response

@joshuahansel joshuahansel added C: Framework P: normal A defect affecting operation with a low possibility of significantly affects. T: defect An anomaly, which is anything that deviates from expectations. labels Mar 20, 2025
@joshuahansel joshuahansel self-assigned this Mar 20, 2025
joshuahansel added a commit to joshuahansel/moose that referenced this issue Mar 20, 2025
@joshuahansel joshuahansel linked a pull request Mar 20, 2025 that will close this issue
joshuahansel added a commit to joshuahansel/moose that referenced this issue Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Framework P: normal A defect affecting operation with a low possibility of significantly affects. T: defect An anomaly, which is anything that deviates from expectations.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant