Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/xsf/amos/amos.h
Original file line number Diff line number Diff line change
Expand Up @@ -4476,6 +4476,8 @@ namespace amos {
//
s1 = w[0];
s2 = w[1];
// int l;
// for (l = 3; l < (nn + 1); l++) {
l = 3;
for (int l = 3; l < (nn + 1); l++) {
ck = s2;
Expand Down
22 changes: 22 additions & 0 deletions tests/xsf_tests/test_amos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,28 @@ TEST_CASE("amos besi vectorized", "[amos][xsf_tests]") {
}
}

TEST_CASE("amos seri buffer overflow gh-92", "[amos][xsf_tests]") {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to run this test on upstream/main and it still passes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I tried again and for me the test fails if I revert the fix. I reverted the fix and pushed to see what CI says.

@JaRoSchm JaRoSchm Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, looks like you are using macOS? Then CI agrees with you. On Linux CI reproduces the failure I observe. So the effect of the bug might be ill-defined in C++ and gcc/clang give different results. Could this be the origin of the differences?

Would you be willing to merge if I revert the last commit? Looks like we agree that the fix is correct and we have a regression test at least for some of the CI jobs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think those are memory bugs. I would expect CI to fail for all three Operating Systems.

using std::complex;

// parameters for besh which trigger overflow in seri
const complex<double> z{14.0, -3.0};
const double fnu = 1.0;
const int m = 1;
const int n = 260;
const int kode = 1;

// allocate n+1 elements, initialize extra to sentinel to detect overflow
const complex<double> sentinel{12345.67, 98765.43};
std::vector<complex<double>> cy(n + 1, sentinel);

int ierr = 0;
int nz = xsf::amos::besh(z, fnu, kode, m, n, cy.data(), &ierr);

// check if the extra element (index n) was touched
CAPTURE(cy[n]);
CHECK(cy[n] == sentinel);
Comment thread
JaRoSchm marked this conversation as resolved.
Outdated
}

TEST_CASE("amos asyi buffer overflow gh-158", "[amos][xsf_tests]") {
using std::complex;

Expand Down
Loading