필터 지우기
필터 지우기

mex call with fftw_threads causes CRASH AFTER CLOSING MATLAB

조회 수: 15 (최근 30일)
Ulrike Springer
Ulrike Springer 2021년 2월 2일
편집: Rena Berman 2024년 7월 16일 16:58
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!

답변 (1개)

Yukthi S
Yukthi S 2024년 6월 5일
편집: Rena Berman 2024년 7월 16일 16:58
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.

카테고리

Help CenterFile Exchange에서 Write C Functions Callable from MATLAB (MEX Files)에 대해 자세히 알아보기

제품


릴리스

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by