Segmentation Violation Error in Mex file: How can I find the line of code

Hi All,
Sometimes when I call a Mex function, following segmentation violation detected. I was wondering how can I find which line of code has the error. It seems that it should be within the function of MySortI, but which line I don't know. Can anybody tell us what does numbers like 5833 and 382(in ... FLKS1C.mexw32+00005822 My_sortI+000382)mean? Can they help us find the C line in Visual studio disassembly window?
Thanks Mohammad
Stack trace:
MATLAB crash file:C:\DOCUME~1\MALIZA~1\LOCALS~1\Temp\matlab_crash_dump.5228:
------------------------------------------------------------------- Segmentation violation detected at Mon Jan 23 01:56:32 2012 ------------------------------------------------------------------- Configuration: MATLAB Version: 7.11.0.584 (R2010b) MATLAB License: 596663 Operating System: Microsoft Windows XP Window System: Version 5.1 (Build 2600: Service Pack 3) Processor ID: x86 Family 6 Model 7 Stepping 6, GenuineIntel Virtual Machine: Java 1.6.0_17-b04 with Sun Microsystems Inc. Java HotSpot™ Client VM mixed mode Default Encoding: windows-1256
Fault Count: 1 Abnormal termination: Register State (from fault): EAX = 0e4f9cd0 EBX = 7bd17620 ECX = 0dfd5f90 EDX = 0dfd5f90 ESP = 00c2c6ec EBP = 00c2c71c ESI = 1e293510 EDI = 1d5fe3c0
EIP = 0dce16be EFL = 00210206
CS = 0000001b DS = 00000023 SS = 00000023
ES = 00000023 FS = 0000003b GS = 00000000
Stack Trace (from fault): [ 0] 0x0dce16be C:/data/MyPHD/FLKS/MEX/FLKS1C.mexw32+00005822 My_sortI+000382 [ 1] 0x0dce3dc8 C:/data/MyPHD/FLKS/MEX/FLKS1C.mexw32+00015816 mexFunction+001480 [ 2] 0x7b833394 C:/Program Files/MATLAB/R2010b/bin/win32/libmex.dll+00013204 ( mexRunMexFile+000132 ) [ 3] 0x7b832199 C:/Program Files/MATLAB/R2010b/bin/win32/libmex.dll+00008601 ( inSwapMexfileReader+000201 ) [ 4] 0x7b832391 C:/Program Files/MATLAB/R2010b/bin/win32/libmex.dll+00009105 ( inSwapMexfileReader+000705 ) [ 5] 0x7a29b0f9 C:/Program Files/MATLAB/R2010b/bin/win32/m_dispatcher.dll+00045305 ( Mfh_file::dispatch_fh+000249 ) [ 6] 0x7a29b384 C:/Program Files/MATLAB/R2010b/bin/win32/m_dispatcher.dll+00045956 ( Mfunction_handle::dispatch+000420 ) [ 7] 0x7aa42881 C:/Program Files/MATLAB/R2010b/bin/win32/m_interpreter.dll+00534657 ( MathWorks::MException::MExceptionEnvelope::MExceptionEnvelope+384993 ) [ 8] 0x7aa2fc9a C:/Program Files/MATLAB/R2010b/bin/win32/m_interpreter.dll+00457882 ( MathWorks::MException::MExceptionEnvelope::MExceptionEnvelope+308218 )
.... .... Rest of stack trace not copied here.

1 Comment

Can you post the code? A debugger might not help, since the crash can result from a coding error upstream of the crash. I.e., even if you could pinpoint the line of code where the crash occurs, *that* line might look perfectly fine but an upstream coding error may have passed invalid pointers etc to the downstream line.

Sign in to comment.

Answers (1)

0x0dce16be C:/data/MyPHD/FLKS/MEX/FLKS1C.mexw32+00005822 My_sortI+000382
means that the run-time address at which the fault occurred was the instruction at memory location 0x0dce16be (hex). This is offset 00005822 (hex) into the code of the file C:/data/MyPHD/FLKS/MEX/FLKS1C.mexw32 . In particular this is offset 000382 into routine My_sortI .
In order to find out exactly which line of code that is, you should be able to use a debugger, especially the debugger that came with the compilers you used.
(I never debugged programs under MS Windows, so I cannot offer advise as to specific commands in the debugger. Now if you were running under the original MS Windows, then my knowledge of CP/M would be applicable ;-) And if you've never heard of CP/M... it was an operating system that was popular about a decade before you were born.)

1 Comment

Thanks Walter, actually when I started working with Dos 3.x I used to see CP/M frequently in documents as it's a kind of predecessor of DOS.
I couldn't match those offsets when I looked in disassembler. I'll check them again. maybe they are decimal values!

Sign in to comment.

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products

Asked:

on 22 Jan 2012

Community Treasure Hunt

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

Start Hunting!