Seg fault associated with MEX file?
4 views (last 30 days)
Show older comments
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 Comment
sourish
on 18 Nov 2011
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.
Accepted Answer
Walter Roberson
on 26 Aug 2011
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 Comment
Kaustubha Govind
on 18 Nov 2011
+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
More Answers (0)
See Also
Categories
Find more on Write C Functions Callable from MATLAB (MEX Files) 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!