FFTW plan gets clobbered when module is compiled

The plan contains a raw pointer to a C data structure in FFTW. If you are using a module in a package, so that it’s precompiled, then the pointer is saved during precompilation but when the module is loaded it no longer points to valid memory.

If you want to initialize global plans in a module, you’ll need to initialize them in the module’s __init__ function so that they are initialized/re-created every time the module is loaded.

3 Likes