- 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)
mex call with fftw_threads causes CRASH AFTER CLOSING MATLAB
3 views (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
Yukthi S
on 5 Jun 2024
Edited: Rena Berman
on 16 Jul 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:
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.
0 Comments
See Also
Categories
Find more on MATLAB Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!