Segmentation violation with DASSL using mex Fortran MATLAB interface



Hi,

I encounter problem while trying to run DASSL using the mex interface between fortran and MATLAB.

I was wondering if one of you faced similar problems and knew how to fix that.

Thank you!

That is, I installed gnumex, Cygwin , and Mingw according to

http://gnumex.sourceforge.net/

and built the mex interface between fortran and MATLAB 6.5.1.

It would compile the fortran files of the specific solver

http://www.engineering.ucsb.edu/~cse/software.html

and an interface

http://www.andrew.cmu.edu/user/steinhau/Research/mex-interfaces.html

I want to work with but it would not run them and crash. Please see below. This is very similar to the behavior of MATLAB 7.1 i..e it used to crash over there, too. I was hoping that MATLAB 6.5.1 would be able to run it.



cd MexInterface_CarnegieMellon_SteinarHauan\
ls
ODESolversNetlib.htm dassl mex-interfaces.html
.. README.dassl dassl.tar.gz
cd dassl\dassl-2.2\
ls
Dassl.f Makefile.bak dassl.doc dasst.f run
.. Dassl.m Makefile~ dassl.pdf examples
Contents.m Makefile README.dassl dassl.txt old
mex -f C:\ThesisWork_HG\mex\mexopts\mexopts.bat -v -O -output Dassl Dassl.f dasst.f
This is mex, Copyright 1984-2002 The MathWorks, Inc.

-> Options file specified on command line
----------------------------------------------------------------
-> Options file = C:\ThesisWork_HG\mex\mexopts\mexopts.bat
MATLAB = C:\MATLAB~1
-> COMPILER = gcc
-> Compiler flags:
COMPFLAGS = -c -DMATLAB_MEX_FILE -mrtd -fcase-upper -fno-underscoring -fleading-underscore
OPTIMFLAGS = -O3 -malign-double -fno-exceptions -mcpu=pentium
DEBUGFLAGS = -g
arguments =
Name switch = -o
-> Pre-linking commands =
-> LINKER = C:\MATLAB~1\sys\perl\win32\bin\perl.exe c:\gnumex\linkmex.pl
-> Link directives:
LINKFLAGS =
LINKFLAGSPOST =
Name directive = -o Dassl.dll
File link directive =
Lib. link directive =
Rsp file indicator =
-> Resource Compiler = C:\MATLAB~1\sys\perl\win32\bin\perl.exe c:\gnumex\rccompile.pl -o mexversion.res
-> Resource Linker =
----------------------------------------------------------------


--> "gcc -c -DMATLAB_MEX_FILE -mrtd -fcase-upper -fno-underscoring -fleading-underscore -oDassl.obj -O3 -malign-double -fno-exceptions -mcpu=pentium Dassl.f"


--> "gcc -c -DMATLAB_MEX_FILE -mrtd -fcase-upper -fno-underscoring -fleading-underscore -odasst.obj -O3 -malign-double -fno-exceptions -mcpu=pentium dasst.f"


--> "C:\MATLAB~1\sys\perl\win32\bin\perl.exe c:\gnumex\linkmex.pl -o Dassl.dll -s Dassl.obj dasst.obj "

ls
Contents.m Dassl.f Makefile Makefile~ dassl.doc dassl.txt examples run
.. Dassl.dll Dassl.m Makefile.bak README.dassl dassl.pdf dasst.f old

tst1
------------------------------------------------------------------------
Segmentation violation detected at Wed Jun 28 20:26:59 2006
------------------------------------------------------------------------
Configuration:
MATLAB Version: 6.5.1.199709 (R13) Service Pack 1
Operating System: Microsoft Windows XP
Window System: Version 5.1 (Build 2600: Service Pack 2)
Processor ID: x86 Family 15 Model 2 Stepping 9, GenuineIntel
Virtual Machine: Java 1.3.1_01 with Sun Microsystems Inc. Java HotSpot(TM) Client VM
(mixed mode)
Register State:
EAX = 20202020 EBX = 022e1250
ECX = 008b6b82 EDX = 022e124c
ESI = 00000004 EDI = 02324000
EBP = 00dfbdd8 ESP = 00dfbdcc
EIP = 7b14c9f9 FLG = 00010206
Stack Trace:
[0] libmx.dll:_MXGETSTRING@16(0, 0x0231dbb8 "dydt ..", 0x022e1250, 4) + 105 bytes
[1] Dassl.dll:0x022e1328(0x00dfc4ec, 0x00dfc874, 0x00dfc4f4, 0x00dfc978)
[2] libmex.dll:_mexRunMexFile(3, 0x00dfc874, 8, 0x00dfc978) + 50 bytes
[3] m_interpreter.dll:void __cdecl inCallMexFunction(int,struct mxArray_tag * * const,int,struct mxArray_tag * * const,void (__cdecl*)(int,struct mxArray_tag * * const,int,struct mxArray_tag * * const),struct _mex_context *,struct mexfiles *)(3, 0x00dfc874, 8, 0x00dfc978) + 476 bytes
[4] m_interpreter.dll:void __cdecl inRunMexFile(int,struct mxArray_tag * * const,int,struct mxArray_tag * * const,struct mexfiles *)(3, 0x00dfc874, 8, 0x00dfc978) + 126 bytes
[5] m_interpreter.dll:void __cdecl inExecMexFile(int,int,struct mxArray_tag * * const,struct MATLAB_Function_tag *)(3, 8, 0x00dfc978, 0x01503758) + 82 bytes
[6] m_interpreter.dll:_inExecFunction(3, 8, 0x00dfc978, 0x01503758) + 38 bytes
[7] m_interpreter.dll:_inMMexExecute(600, 0x01503758, 3, 8) + 533 bytes
[8] m_interpreter.dll:enum opcodes __cdecl inMMex(char const *,int,int,int,int *,int *)(0x0142d254 "Dassl", 0, 3, 8) + 94 bytes
[9] m_interpreter.dll:int __cdecl inInterp(enum inDebugCheck,int,int,struct inPcodeNest_tag volatile *)(1, 23, 0, 0x013b8230) + 1982 bytes
[10] m_interpreter.dll:_inInterPcode(1, 0x00dfcdc0, 0, 0x16f2f628) + 193 bytes
[11] m_interpreter.dll:_inExecCompScript(0x16f2f628, 0x16f2f628, 0x00dfd3cc, 0x00dfd698 "°Öß") + 991 bytes
[12] m_interpreter.dll:bool __cdecl inRunMP(int,struct mxArray_tag * *,int,struct mxArray_tag * *,struct word *,bool)(0, 0x00dfd3cc, 0, 0x00dfd6d4) + 106 bytes
[13] m_interpreter.dll:void __cdecl inExecMFile(int,int,struct mxArray_tag * * const,struct MATLAB_Function_tag *)(0, 0, 0x00dfd6d4, 0x16f2f628) + 70 bytes
[14] m_interpreter.dll:_inExecFunction(0, 0, 0x00dfd6d4, 0x16f2f628) + 38 bytes
[15] m_interpreter.dll:_inMMexExecute(618, 0x16f2f628, 0, 0) + 533 bytes
[16] m_interpreter.dll:enum opcodes __cdecl inMMex(char const *,int,int,int,int *,int *)(0x170afe3c "tst1", 618, 0, 0) + 94 bytes
[17] m_interpreter.dll:int __cdecl inInterp(enum inDebugCheck,int,int,struct inPcodeNest_tag volatile *)(2, 0, 0, 0x013af9f8) + 2143 bytes
[18] m_interpreter.dll:_inInterPcode(2, 0x00dfdc54, 0, 0) + 193 bytes
[19] m_interpreter.dll:enum inExecutionStatus __cdecl in_local_call_eval_function(int *,struct _m_parser_interface *,struct _pcodeheader *,int *,struct mxArray_tag * * const,enum inDebugCheck)(0, 0x7a8afa78, 0x00dfdc54, 0x00dfdcf8) + 174 bytes
[20] m_interpreter.dll:_inEvalStringWithIsVarFcn(0x16fdb030 "tst1\n", 5, 0, 0) + 531 bytes
[21] m_interpreter.dll:_inEvalString(0x16fdb030 "tst1\n", 5, 0, 0) + 50 bytes
[22] m_interpreter.dll:enum inExecutionStatus __cdecl inEvalCmdWithLocalReturnandtype(char const *,int *,enum inDebugCheck)(0x16fdb030 "tst1\n", 0, 2, 0x00dfde30) + 68 bytes
[23] m_interpreter.dll:_inEvalCmdNoEnd(0x16fdb030 "tst1\n", 1, 0x0047f62f, 11) + 16 bytes
[24] matlab.exe:_mnParser(0x0159dd60, 336780, 0, 48) + 1001 bytes
[25] matlab.exe:_WinMain@16(0x00400000 "MZ?", 0, 336780, 1) + 3864 bytes
[26] matlab.exe:_WinMainCRTStartup(0x0159dd60, 0x7c90e1fe "¸±", 0x7ffd8000, 0x8054a938) + 308 bytes
[27] kernel32.dll:0x7c816d4f(0x00471aae, 0, 0, 0)
This error was detected while a MEX
-file was running. If the MEX-file
is not an official MathWorks function, please examine its source code
for errors. Please consult the External Interfaces Guide for information
on debugging MEX-files.
If it is an official MathWorks function, please
follow these steps in reporting this problem to The MathWorks so
that we have the best chance of correcting it:
1. Send this crash report to segv@xxxxxxxxxxxxx for automated analysis.
For your convenience, this information has been recorded in:
C:\DOCUME~1\student\LOCALS~1\Temp\matlab_crash_dump.3100
2. Also, if the problem is reproducible, send the crash report to
support@xxxxxxxxxxxxx along with:
- A specific list of steps that will reproduce the problem
- Any M, MEX, MDL or other files required to reproduce the problem
- Any error messages displayed prior to this crash report
A technical support engineer will contact you with further information.
Thank you for your assistance. Please save your workspace and restart
MATLAB before continuing your work.
Error in ==> C:\ThesisWork_HG\DASSL\MexInterface_CarnegieMellon_SteinarHauan\dassl\dassl-2.2\run\Dassl.dll
Error in ==> C:\ThesisWork_HG\DASSL\MexInterface_CarnegieMellon_SteinarHauan\dassl\dassl-2.2\run\tst1.m
On line 23 ==> [IDID,NRS,YM]=Dassl(Nm,t0,tf,NEQ,Y0,RTOL,ATOL,RPAR);



and in MATLAB 7.1:


mex -f C:\gnumex\mexopts.bat dassl.f dasst.f
tst1

------------------------------------------------------------------------
Segmentation violation detected at Wed Feb 08 23:10:17 2006
------------------------------------------------------------------------

Configuration:
MATLAB Version: 7.1.0.246 (R14) Service Pack 3
MATLAB License: 207456
Operating System: Microsoft Windows XP
Window System: Version 5.1 (Build 2600: Service Pack 1)
Processor ID: x86 Family 6 Model 13 Stepping 6, GenuineIntel
Virtual Machine: Java 1.5.0 with Sun Microsystems Inc. Java HotSpot(TM) Client VM mixed mode
Default Charset: windows-1252

Register State:
EAX = 20202020 EBX = 6ca81250
ECX = 1b29eb82 EDX = 6ca8124c
ESI = 00000004 EDI = 6cac4000
EBP = 00cdd0cc ESP = 00cdd0c0
EIP = 785178aa FLG = 00010216

Stack Trace:
[0] libmx.dll:_MXGETSTRING@16(0, 0x6cabdbb8 "dydt ..", 0x6ca81250, 4) + 138 bytes
[1] dassl.dll:0x6ca81328(0x00cdd7f0, 0x00cddf2c, 0x00cdd7f8, 0x00cddf8c)
[2] libmex.dll:_mexRunMexFile(3, 0x00cddf2c, 8, 0x00cddf8c) + 82 bytes
[3] libmex.dll:private: void __thiscall Mfh_mex::runMexFileWithSignalProtection(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(3, 0x00cddf2c, 8, 0x00cddf8c) + 73 bytes
[4] libmex.dll:public: virtual void __thiscall Mfh_mex::dispatch_file(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(3, 0x00cddf2c, 8, 0x00cddf8c) + 169 bytes
[5] m_dispatcher.dll:public: virtual void __thiscall Mfh_file::dispatch_fh(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(3, 0x00cddf2c, 8, 0x00cddf8c) + 271 bytes
[6] m_interpreter.dll:int __cdecl mdDispatch(int,char const *,int,struct mxArray_tag * *,int,struct mxArray_tag * *,class Mfh_MATLAB_fn * *)(523, 0x100c095b "dassl", 3, 0x00cddf2c) + 88 bytes
[7] m_interpreter.dll:_inDispatchFromStack(523, 0x100c095b "dassl", 3, 8) + 800 bytes
[8] m_interpreter.dll:_inCallFcnFromReference(0x042dfd70, 0xffffffff, 0x78746220, 0) + 164 bytes
[9] m_interpreter.dll:int __cdecl inInterp(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag volatile *,int *)(1, 0, 23, 0) + 4527 bytes
[10] m_interpreter.dll:int __cdecl inInterPcodeSJ(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag *,int *)(1, 0, 10, 0) + 282 bytes
[11] m_interpreter.dll:int __cdecl inExecuteMFunctionOrScript(class Mfh_mp *,bool)(0x03d5fc20, 1, 0, 0x786ca8c0) + 724 bytes
[12] m_interpreter.dll:_inExecCompScript(0, 0x00cde660, 0x03d5fc20, 0xffffffff) + 327 bytes
[13] m_interpreter.dll:public: void __thiscall Mfh_mp::inRunMP(int,struct mxArray_tag * *,int,struct mxArray_tag * *,struct inWorkSpace_tag *)(0, 0x00cde660, 0, 0x00cde6c0) + 128 bytes
[14] m_interpreter.dll:public: virtual void __thiscall Mfh_mp::dispatch_file(struct _mdUnknown_workspace *,int,struct mxArray_tag * *,int,struct mxArray_tag * *)(0, 0, 0x00cde660, 0) + 28 bytes
[15] m_interpreter.dll:public: virtual void __thiscall Mfh_mp::dispatch_file(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(0, 0x00cde660, 0, 0x00cde6c0) + 26 bytes
[16] m_dispatcher.dll:public: virtual void __thiscall Mfh_file::dispatch_fh(int,struct mxArray_tag * *,int,struct mxArray_tag * *)(0, 0x00cde660, 0, 0x00cde6c0) + 271 bytes
[17] m_interpreter.dll:int __cdecl mdDispatch(int,char const *,int,struct mxArray_tag * *,int,struct mxArray_tag * *,class Mfh_MATLAB_fn * *)(522, 0x01e453a4 "tst1", 0, 0x00cde660) + 88 bytes
[18] m_interpreter.dll:_inDispatchFromStack(522, 0x01e453a4 "tst1", 0, 0) + 800 bytes
[19] m_interpreter.dll:enum opcodes __cdecl inDispatchCall(char const *,int,int,int,int *,int *)(0x01e453a4 "tst1", 522, 0, 0) + 145 bytes
[20] m_interpreter.dll:int __cdecl inInterp(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag volatile *,int *)(2, 0, 0, 0) + 2534 bytes
[21] m_interpreter.dll:int __cdecl inInterPcodeSJ(enum inDebugCheck,int,int,enum opcodes,struct inPcodeNest_tag *,int *)(2, 0, 0, 0) + 282 bytes
[22] m_interpreter.dll:_inInterPcode(2, 0x784d6e7c, 0, 0) + 81 bytes
[23] m_interpreter.dll:enum inExecutionStatus __cdecl in_local_call_eval_function(int *,struct _pcodeheader *,int *,struct mxArray_tag * * const,enum inDebugCheck)(0x00cdf278, 0x00cdf370, 2, 1) + 153 bytes
[24] m_interpreter.dll:$L74683(0x784d6e7c, 0x04124420 "tst1\n", 0, 0) + 184 bytes
[25] m_interpreter.dll:enum inExecutionStatus __cdecl inEvalCmdWithLocalReturnandtype(char const *,int *,enum inDebugCheck)(0x04124420 "tst1\n", 0, 2, 0x00cdf3bc "DôÍ") + 69 bytes
[26] m_interpreter.dll:_inEvalCmdNoEnd(0x04124420 "tst1\n", 1, 255, 0) + 16 bytes
[27] bridge.dll:enum inExecutionStatus __cdecl ThrowSignal(char const *)(0x04124420 "tst1\n", 0x77e5ad86, 0x01207468, 0x01207468) + 60 bytes
[28] bridge.dll:$L86781(0, 0, 0x784d6e58, 0x7c36b71f) + 432 bytes
[29] mcr.dll:public: void __thiscall mcrInstance::mnParser(void)(336813, 0x505c3a43, 0x72676f72, 0x656d6d61) + 93 bytes
[30] MATLAB.exe:0x00401ca9(4194304, 0, 336813, 0x01207468)
[31] MATLAB.exe:0x00403d9f(0x70a9f1ab, 0x80000002, 0x7ffdf000, 0xef27dcf0)
[32] kernel32.dll:0x77e614c7(0x00403c1a, 0, 0, 0)

This error was detected while a MEX-file was running. If the MEX-file
is not an official MathWorks function, please examine its source code
for errors. Please consult the External Interfaces Guide for information
on debugging MEX-files.

If it is an official MathWorks function, please
follow these steps in reporting this problem to The MathWorks so
that we have the best chance of correcting it:

1. Send this crash report to segv@xxxxxxxxxxxxx for automated analysis.
For your convenience, this information has been recorded in:
C:\DOKUME~1\hg\LOKALE~1\Temp\matlab_crash_dump.2728

2. Also, if the problem is reproducible, send the crash report to
support@xxxxxxxxxxxxx along with:
- A specific list of steps that will reproduce the problem
- Any M, MEX, MDL or other files required to reproduce the problem
- Any error messages displayed to the command window
A technical support engineer will contact you with further information.

Thank you for your assistance. Please save your workspace and restart
MATLAB before continuing your work.

Error in ==> tst1 at 23
[IDID,NRS,YM]=dassl(Nm,t0,tf,NEQ,Y0,RTOL,ATOL,RPAR);
.



Relevant Pages