FFTW / fftw3

DO NOT CHECK OUT THESE FILES FROM GITHUB UNLESS YOU KNOW WHAT YOU ARE DOING. (See below.)
GNU General Public License v2.0
2.66k stars 651 forks source link

Smallbin double linked list corruption for specific data #345

Closed AurusHuang closed 6 months ago

AurusHuang commented 6 months ago

debug-8-7298.csv

On my machine (Rocky Linux 8.9; FFTW 3.3.5), when loading this data and execute FFTW, it reports a smallbin double linked list corruption. I'm also using xtensor-fftw, so I also opened an issue there (link)

The example is as following (C++ code):

fstream fs_debug;
fs_debug.open("/home/winfred/l1b-pro/data/output/debug-8-7298.csv", ios::in);
xtensor<float, 2> delta_sigx_han_t = xt::load_csv<float>(fs_debug);
xtensor<float, 1> delta_sigx_han_tt = xt::zeros<float>({delta_sigx_han_t.size()});
for (int i = 0; i < delta_sigx_han_t.size(); i++)
{
    delta_sigx_han_tt(i) = delta_sigx_han_t(0, i);
}
auto pdsig_t = xt::fftw::rfft(delta_sigx_han_tt);
stevengj commented 6 months ago

Not clear to me that this is a corruption in FFTW itself rather than a bug in xtensor.

AurusHuang commented 5 months ago

@stevengj Wait! I changed my code as the following and the error still exists.

fstream fs_debug;
fs_debug.open("/home/winfred/l1b-pro/data/output/debug-8-7298.csv", ios::in);

vector<float> v_result;
string cell;
while (std::getline(fs_debug, cell, ','))
{
    v_result.push_back(stof(cell));
}
// This checks for a trailing comma with no data after it.
if (!fs_debug && cell.empty())
{
}

cout << v_result.size() << endl;    // 4096

vector<fftw_complex> result(v_result.size());
fftw_complex *in = reinterpret_cast<fftw_complex *>(fftw_malloc(sizeof(fftw_complex) * v_result.size()));

for (int i = 0; i < v_result.size(); ++i)
{
    in[i][0] = v_result[i];
    in[i][1] = 0.0;
}

fftw_complex *out = reinterpret_cast<fftw_complex *>(fftw_malloc(sizeof(fftw_complex) * v_result.size()));
fftw_plan plan = fftw_plan_dft_1d(v_result.size(), in, out, FFTW_FORWARD, FFTW_ESTIMATE);

fftw_execute(plan);

fftw_destroy_plan(plan);