MatLab Mex文件每三次运行崩溃



我目前正在尝试从glmnet包(http://web.stanford.edu/~hastie/glmnet_matlab/index.html)运行代码。它在此过程中调用mex文件。当我在前两次运行包中的函数时,它工作得很好。每三次尝试,MatLab都会给出一个"灾难性"错误,并要求我关闭它。它可能是与mex文件的内存分配有关吗?我想知道这是否可能是mex文件用户的常见问题。谢谢。

编辑:这是"灾难性"错误:

------------------------------------------------------------------------
          Access violation detected at Mon Jul 13 13:20:32 2015
------------------------------------------------------------------------
Configuration:
  Crash Decoding      : Disabled
  Crash Mode          : continue (default)
  Current Graphics Driver: Unknown hardware 
  Default Encoding    : windows-1252
  Graphics card 1     : NVIDIA ( 0x10de ) NVIDIA GeForce GT 740M Version 9.18.13.4752
  Graphics card 2     : Intel Corporation ( 0x8086 ) Intel(R) HD Graphics 4000 Version 10.18.10.3308
  Host Name           : Marcelo
  MATLAB Architecture : win64
  MATLAB Root         : C:Program FilesMATLABMATLAB Production ServerR2015a
  MATLAB Version      : 8.5.0.197613 (R2015a)
  OpenGL              : hardware
  Operating System    : Microsoft Windows 8.1 Single Language
  Processor ID        : x86 Family 6 Model 58 Stepping 9, GenuineIntel
  Virtual Machine     : Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
  Window System       : Version 6.3 (Build 9600)
Fault Count: 1

Abnormal termination:
Access violation
Register State (from fault):
  RAX = 00006e6f69746365  RBX = 0000000000000000
  RCX = 0000000004032bf0  RDX = 0000000000000000
  RSP = 0000000004031108  RBP = 0000000004032ce0
  RSI = 00000000f69ef970  RDI = 0000000004032be0
   R8 = 000000007fc60fc0   R9 = 0000000000000006
  R10 = 000000007fefd750  R11 = 000000007fefd750
  R12 = 0000000000000001  R13 = 0000000000000000
  R14 = 0000000004032ce0  R15 = 0000000004032be0
  RIP = 00000000fe16e073  EFL = 00010206
   CS = 0033   FS = 0053   GS = 002b
Stack Trace (from fault):
[  0] 0x00000000fe16e073 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64libmx.dll+00450675 MXGETPR+00000003
[  1] 0x00007ff87cdc1a95 C:UsersMarceloDesktopMarceloPUCMestradoDissInstrumentSelectionglmnet_matlabglmnetMex.mexw64+00006805 MEXFUNCTION+00002709
[  2] 0x00000000fc5f3740 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64libmex.dll+00079680 mexRunMexFile+00000112
[  3] 0x00000000fc5f2a72 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64libmex.dll+00076402 inSwapMexfileReader+00000594
[  4] 0x00000000fc5f25c8 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64libmex.dll+00075208 mexUnlock+00002840
[  5] 0x0000000004f22694 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_dispatcher.dll+00075412 Mfh_file::dispatch_fh+00000548
[  6] 0x0000000004f22a7e C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_dispatcher.dll+00076414 Mfunction_handle::dispatch+00000766
[  7] 0x0000000005059597 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00103831 in_is_matlab_function+00048455
[  8] 0x000000000505a1ab C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00106923 in_is_matlab_function+00051547
[  9] 0x000000000512684f C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00944207 MathWorks::MException::MExceptionEnvelope::MCOSClassID+00000991
[ 10] 0x00000000051267b1 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00944049 MathWorks::MException::MExceptionEnvelope::MCOSClassID+00000833
[ 11] 0x000000000509da75 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00383605 inGetCurrentWS+00155269
[ 12] 0x000000000509ce8c C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00380556 inGetCurrentWS+00152220
[ 13] 0x000000000509b6e9 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00374505 inGetCurrentWS+00146169
[ 14] 0x0000000004f22694 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_dispatcher.dll+00075412 Mfh_file::dispatch_fh+00000548
[ 15] 0x0000000004f22a7e C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_dispatcher.dll+00076414 Mfunction_handle::dispatch+00000766
[ 16] 0x0000000005059597 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00103831 in_is_matlab_function+00048455
[ 17] 0x000000000505a1ab C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00106923 in_is_matlab_function+00051547
[ 18] 0x000000000512684f C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00944207 MathWorks::MException::MExceptionEnvelope::MCOSClassID+00000991
[ 19] 0x00000000051267b1 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00944049 MathWorks::MException::MExceptionEnvelope::MCOSClassID+00000833
[ 20] 0x000000000509da75 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00383605 inGetCurrentWS+00155269
[ 21] 0x000000000509ce8c C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00380556 inGetCurrentWS+00152220
[ 22] 0x000000000509b6e9 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00374505 inGetCurrentWS+00146169
[ 23] 0x0000000004f22694 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_dispatcher.dll+00075412 Mfh_file::dispatch_fh+00000548
[ 24] 0x0000000004f22a7e C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_dispatcher.dll+00076414 Mfunction_handle::dispatch+00000766
[ 25] 0x0000000005059597 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00103831 in_is_matlab_function+00048455
[ 26] 0x00000000051731a7 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+01257895 inIsKeyword+00027799
[ 27] 0x000000000505b69a C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00112282 in_is_matlab_function+00056906
[ 28] 0x000000000512684f C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00944207 MathWorks::MException::MExceptionEnvelope::MCOSClassID+00000991
[ 29] 0x00000000051267b1 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00944049 MathWorks::MException::MExceptionEnvelope::MCOSClassID+00000833
[ 30] 0x000000000509da75 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00383605 inGetCurrentWS+00155269
[ 31] 0x000000000509ce8c C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00380556 inGetCurrentWS+00152220
[ 32] 0x000000000509b6e9 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00374505 inGetCurrentWS+00146169
[ 33] 0x0000000004f22757 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_dispatcher.dll+00075607 Mfh_file::dispatch_fh+00000743
[ 34] 0x0000000004f22a7e C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_dispatcher.dll+00076414 Mfunction_handle::dispatch+00000766
[ 35] 0x0000000005059597 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00103831 in_is_matlab_function+00048455
[ 36] 0x00000000051731a7 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+01257895 inIsKeyword+00027799
[ 37] 0x000000000505b69a C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00112282 in_is_matlab_function+00056906
[ 38] 0x000000000512684f C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00944207 MathWorks::MException::MExceptionEnvelope::MCOSClassID+00000991
[ 39] 0x00000000051267b1 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00944049 MathWorks::MException::MExceptionEnvelope::MCOSClassID+00000833
[ 40] 0x000000000509da75 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00383605 inGetCurrentWS+00155269
[ 41] 0x000000000509ce8c C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00380556 inGetCurrentWS+00152220
[ 42] 0x000000000509b6e9 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00374505 inGetCurrentWS+00146169
[ 43] 0x0000000004f22757 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_dispatcher.dll+00075607 Mfh_file::dispatch_fh+00000743
[ 44] 0x0000000004f22a7e C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_dispatcher.dll+00076414 Mfunction_handle::dispatch+00000766
[ 45] 0x000000000512b268 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00963176 inAnonymousFunction+00000360
[ 46] 0x000000000512b864 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00964708 inAnonymousFunction+00001892
[ 47] 0x000000000512ba25 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00965157 inAnonymousFunction+00002341
[ 48] 0x000000000512b9f2 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00965106 inAnonymousFunction+00002290
[ 49] 0x000000000512b9a7 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00965031 inAnonymousFunction+00002215
[ 50] 0x00000000050df6bd C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00652989 inGetCallersWorkSpace+00001805
[ 51] 0x00000000050d854d C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00623949 inEvalCmdWithLocalReturn+00000285
[ 52] 0x00000000050d8471 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64m_interpreter.dll+00623729 inEvalCmdWithLocalReturn+00000065
[ 53] 0x00000000fb5fe82d C:Program FilesMATLABMATLAB Production ServerR2015abinwin64libmwbridge.dll+00059437 mnGetPrompt+00002717
[ 54] 0x00000000fb5ff2a9 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64libmwbridge.dll+00062121 mnParser+00000745
[ 55] 0x00000000fd0e13d4 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64mcr.dll+00398292 mcrInstance::mnParser_on_interpreter_thread+00000036
[ 56] 0x00000000fd0a9757 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64mcr.dll+00169815 mcr::runtime::setInterpreterThreadToCurrent+00019751
[ 57] 0x00000000fd0a9793 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64mcr.dll+00169875 mcr::runtime::setInterpreterThreadToCurrent+00019811
[ 58] 0x00000000fd0a9f91 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64mcr.dll+00171921 mcr::runtime::setInterpreterThreadToCurrent+00021857
[ 59] 0x00000000fab5d216 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64uiw.dll+00512534 UIW_AttachThreadInput+00001270
[ 60] 0x00000000fab5caa5 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64uiw.dll+00510629 wsd_to_MSW+00004373
[ 61] 0x00000000fab5cb29 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64uiw.dll+00510761 wsd_to_MSW+00004505
[ 62] 0x00007ff8ad1708ca                     C:WINDOWSsystem32USER32.dll+00592074 BroadcastSystemMessageExA+00000586
[ 63] 0x00007ff8ad0e2e1f                     C:WINDOWSsystem32USER32.dll+00011807 IsWindow+00000367
[ 64] 0x00007ff8ad0e2e96                     C:WINDOWSsystem32USER32.dll+00011926 IsWindow+00000486
[ 65] 0x00007ff8af413034                      C:WINDOWSSYSTEM32ntdll.dll+00602164 KiUserCallbackDispatcher+00000036
[ 66] 0x00007ff8ad0e2a8a                     C:WINDOWSsystem32USER32.dll+00010890 PeekMessageW+00000250
[ 67] 0x00007ff8ad0e6283                     C:WINDOWSsystem32USER32.dll+00025219 GetMessageA+00000243
[ 68] 0x00007ff8ad0e622f                     C:WINDOWSsystem32USER32.dll+00025135 GetMessageA+00000159
[ 69] 0x00000000fab09bdb C:Program FilesMATLABMATLAB Production ServerR2015abinwin64uiw.dll+00170971 UIW_ShowMenuItem+00005179
[ 70] 0x00000000fab5db52 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64uiw.dll+00514898 UIW_SuspendAttachThreadInput+00000466
[ 71] 0x0000000100122c83 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64libmwservices.dll+01256579 services::system_events::PpeDispatchHook::dispatchOne+00032291
[ 72] 0x000000010012e6f5 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64libmwservices.dll+01304309 sysq::addProcessPendingEventsUnitTestHook+00005813
[ 73] 0x000000010012e7a0 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64libmwservices.dll+01304480 sysq::addProcessPendingEventsUnitTestHook+00005984
[ 74] 0x0000000100130595 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64libmwservices.dll+01312149 sysq::getCondition+00004629
[ 75] 0x0000000100131f52 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64libmwservices.dll+01318738 svWS_ProcessPendingEvents+00000162
[ 76] 0x00000000fd0aa6ad C:Program FilesMATLABMATLAB Production ServerR2015abinwin64mcr.dll+00173741 mcr::runtime::setInterpreterThreadToCurrent+00023677
[ 77] 0x00000000fd0ab31a C:Program FilesMATLABMATLAB Production ServerR2015abinwin64mcr.dll+00176922 mcr::runtime::setInterpreterThreadToCurrent+00026858
[ 78] 0x00000000fd0a2f75 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64mcr.dll+00143221 mcr_process_events+00007557
[ 79] 0x00000000fd0a4882 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64mcr.dll+00149634 mcr_process_events+00013970
[ 80] 0x00000000084ab49d C:Program FilesMATLABMATLAB Production ServerR2015abinwin64MVMLocal.dll+00177309 mvm_server::inproc::LocalFactory::terminate+00048141
[ 81] 0x00000000fa8fa27a C:Program FilesMATLABMATLAB Production ServerR2015abinwin64mvm.dll+00828026 mvm::detail::initLocalMvmHack+00000490
[ 82] 0x00000000fa8fa838 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64mvm.dll+00829496 mvm::detail::SessionImpl::privateSession+00000376
[ 83] 0x00000000fa8faa88 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64mvm.dll+00830088 mvm::detail::SessionImpl::privateSession+00000968
[ 84] 0x000000014000630d C:Program FilesMATLABMATLAB Production ServerR2015abinwin64MATLAB.exe+00025357
[ 85] 0x0000000140007dd0 C:Program FilesMATLABMATLAB Production ServerR2015abinwin64MATLAB.exe+00032208
[ 86] 0x00007ff8acea13d2                   C:WINDOWSsystem32KERNEL32.DLL+00005074 BaseThreadInitThunk+00000034
[ 87] 0x00007ff8af395444                      C:WINDOWSSYSTEM32ntdll.dll+00087108 RtlUserThreadStart+00000052

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 this problem is reproducible, please submit a Service Request via:
    http://www.mathworks.com/support/contact_us/
A technical support engineer might contact you with further information.
Thank you for your help.

总结上面的注释,第一步是使用调试器调试MEX函数。查看这篇关于如何使用基于您正在使用的任何操作系统的IDE来设置它的文章:防止在MATLAB中崩溃MEX文件…因此,在第三次尝试时,找出它在哪一行崩溃。

现在你知道它在哪里崩溃了,你得到了未解决的链接错误。未解决的链接错误来自于试图使用没有可用代码定义的代码/函数。听起来好像有预编译的MEX文件在运行代码时导致了问题。尝试重新编译代码,使其与您的系统最兼容。

64位Windows的说明在这里:http://web.stanford.edu/~hastie/glmnet_matlab/win64compile.html。类似地,32位指令在这里:http://web.stanford.edu/~hastie/glmnet_matlab/win32compile.html。您可以跳过指令中的第二步,因为我相信这一步是由最新版本的MATLAB处理的。


希望这将使事情更稳定!

最新更新