mex call with fftw_threads causes CRASH AFTER CLOSING MATLAB

2 visualizzazioni (ultimi 30 giorni)
strange behavior:
if I work in my matlab source with fft and ifft and then call in the same source my mex-function which works with fftw_threads and of course fftw,ifft, it works very good, but after closing matlab, I'll get "Segmentation violation detected" with something like fftw_plan_awake....
If I do this process the other way around, first call of my mex function and afterwards fft,ifft in my matlab source, closing matlab, I have no "Segmentation violation detected".
As well, if I run my mex-function without fftw_threads everything is fine!! (irrelevant if I call matlab fft then mex fct or mex fct then matlab fft)
In both source, matlab and c-mex-source, I only make some easy standard fft, nothing special. New is the try to work with fftw_threads.
My Question: what happens in the background so that matlab crashes after closing in some constellations?
Thank you!

Risposte (1)

Yukthi S
Yukthi S il 5 Giu 2024
Modificato: Rena Berman il 16 Lug 2024
Hi Ulrike Springer,
I deduce that you are facing a MATLAB crash issue when you first call the “fft” and “ifft” in the MATLAB source and then call MEX-function which has “fftw_threads”.
A potential cause for the crash might be due to the MEX file attempting to invoke the specific "fftw" version it was designed to work with, but instead, it calls upon the "fftw" version that comes with MATLAB. The discrepancy between the two versions leads to MATLAB crashing. To avoid these crashes:
  • Compile the MEX-file using the identical "fftw" version that MATLAB includes.
  • Alternatively, statically link the MEX file with the static version of the "fftw" version you prefer. By doing so, the MEX file will not call the dynamic "fftw" version included with MATLAB.
  • Also, you can use the MATLAB’s built-in “fftw” function instead of calling it through a custom MEX-file. You can find more information in the documentation link: fftw - MATLAB & Simulink (mathworks.com)
Another possible reason might be a bug in the MEX file, or there could be an issue with how memory is allocated, which means you'll need to do more debugging on your MEX file. To find out more about this, you can refer to the documentation below:
Given that you didn't experience the crash when not using "fftw_threads", it suggests there could be situations where the way MATLAB manages threads is incompatible with the threading approach of the MEX file.

Categorie

Scopri di più su MATLAB Compiler in Help Center e File Exchange

Prodotti


Release

R2015a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by