Skip to content

nfft_adjoint() crash with small N_total #34

@krivenko

Description

@krivenko

Dear authors,

I have found that the following simple program crashes (segfault) when compiled and linked against NFFT 3.3.2.

#include "nfft3.h"

int main(void) {
  int N[] = {8};        /* Works for >= 9 */
  int M = 10;
  nfft_plan p;
  nfft_init(&p, 1, N, M);

  for(int i = 0; i < M; ++i) {
   p.x[i] = -0.5 + (double)i / M;
   p.f[i][0] = 1.0;     /* Memory corruption? */
   p.f[i][1] = 0.0;
  }

  if(p.flags & PRE_ONE_PSI) nfft_precompute_one_psi(&p);
  nfft_check(&p);
  nfft_adjoint(&p);     /* Segfault if M <= 6 */
  nfft_vpr_complex(p.f_hat, p.N_total, "adjoint nfft, vector f_hat");
  nfft_finalize(&p);    /* Segfault if M > 6 */
  return 0;
}

Some remarks are to be made about the program.

  • It successfully runs to completion if N is 9 or larger;
  • For M <= 6 the segmentation fault occurs in nfft_adjoint();
  • For larger M it occurs in nfft_finalize();
  • There is no crash if p.f is untouched.

Is this a bug or am I just misusing NFFT?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions