Seg fault associated with MEX file?

4 ビュー (過去 30 日間)
Mike
Mike 2011 年 8 月 25 日
I'm getting a seg fault show up while running a matlab script that includes a call to a MEX file. The MEX file is called exactly once, and I've checked that the crash does not actually happen during the invocation of the MEX file by displaying text just before and after the MEX call. I'm working on trying to narrow down the location of the seg fault, but the script is long and only crashes after a couple of hours so this is tricky. Any other ideas? Here is the crash dump:
Abnormal termination: Segmentation violation
Register State (from fault): EAX = 00ba840f EBX = 01208728 ECX = a3a60fb0 EDX = 1342d000 ESP = 048d8e2c EBP = 048d8e68 ESI = 00bc426b EDI = 00000000
EIP = 00000000 EFL = 00010246
CS = 00000073 DS = 0000007b SS = 0000007b
ES = 0000007b FS = 00000000 GS = 00000033
Stack Trace (from fault): [ 0] 0x00941099 /usr/local/MATLAB/R2011a_Student/bin/glnx86/../../bin/glnx86/libmwfl.so+00450713 fl::sysdep::linux::unwind_stack(void const**, unsigned int, unsigned int, fl::diag::thread_context const&)+000036 [ 1] 0x008f224a /usr/local/MATLAB/R2011a_Student/bin/glnx86/../../bin/glnx86/libmwfl.so+00127562 fl::diag::stacktrace_base::capture(fl::diag::thread_context const&, unsigned int)+000180 [ 2] 0x008fc473 /usr/local/MATLAB/R2011a_Student/bin/glnx86/../../bin/glnx86/libmwfl.so+00169075 [ 3] 0x008fc845 /usr/local/MATLAB/R2011a_Student/bin/glnx86/../../bin/glnx86/libmwfl.so+00170053 fl::diag::terminate_log(char const*, fl::diag::thread_context const&, bool)+000115 [ 4] 0x002c0a0f /usr/local/MATLAB/R2011a_Student/bin/glnx86/../../bin/glnx86/libmwmcr.so+00375311 fl::diag::terminate_log(char const*, ucontext const*, bool)+000096 [ 5] 0x002bd8a6 /usr/local/MATLAB/R2011a_Student/bin/glnx86/../../bin/glnx86/libmwmcr.so+00362662 [ 6] 0x002bf56e /usr/local/MATLAB/R2011a_Student/bin/glnx86/../../bin/glnx86/libmwmcr.so+00370030 [ 7] 0x002c0154 /usr/local/MATLAB/R2011a_Student/bin/glnx86/../../bin/glnx86/libmwmcr.so+00373076 [ 8] 0x004c3410 __kernel_rt_sigreturn+000000
  1 件のコメント
sourish
sourish 2011 年 11 月 18 日
Try this to see if it works:
Step 1: load intel fortran compiler (ifort) onto your system
Step 2: In the matlab prompt, >>mex FC="ifort" filename.F (which means I am over riding the probable default gfortran with ifort)
Step 3: YOURLHS=filename(YOURRHS)
If this works, then it may imply that the problem is occurring in gfortran working on 64 bit architecture.
Hope this helps.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2011 年 8 月 26 日
In such cases, your mex file has probably overwritten a pointer, or overwritten a data area that does not belong to it but which other code is depending upon to be correct. Or your mex file might be free()'ing something that it should not be.
  1 件のコメント
Kaustubha Govind
Kaustubha Govind 2011 年 11 月 18 日
+1
If you have the source code for the MEX-function, it may be useful to try debugging the file. See this page for information on debugging: http://www.mathworks.com/help/techdoc/matlab_external/f32489.html

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWrite C Functions Callable from MATLAB (MEX Files) についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by