0

I am currently trying to run codes from the glmnet package (http://web.stanford.edu/~hastie/glmnet_matlab/index.html). It calls mex files during the process. When I run the functions from the package for the first two times, it works fine. Every third time I try, MatLab gives a "catastrophic" error and requires me to close it. Can it possibly be something with memory allocation from mex files? I was wondering if this may be a common problem for mex files user. Thanks.

EDIT: Here is the "catastrophic" error:

------------------------------------------------------------------------
          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 Files\MATLAB\MATLAB Production Server\R2015a
  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 Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\libmx.dll+00450675 MXGETPR+00000003
[  1] 0x00007ff87cdc1a95 C:\Users\Marcelo\Desktop\Marcelo\PUC\Mestrado\Diss\InstrumentSelection\glmnet_matlab\glmnetMex.mexw64+00006805 MEXFUNCTION+00002709
[  2] 0x00000000fc5f3740 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\libmex.dll+00079680 mexRunMexFile+00000112
[  3] 0x00000000fc5f2a72 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\libmex.dll+00076402 inSwapMexfileReader+00000594
[  4] 0x00000000fc5f25c8 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\libmex.dll+00075208 mexUnlock+00002840
[  5] 0x0000000004f22694 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_dispatcher.dll+00075412 Mfh_file::dispatch_fh+00000548
[  6] 0x0000000004f22a7e C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_dispatcher.dll+00076414 Mfunction_handle::dispatch+00000766
[  7] 0x0000000005059597 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00103831 in_is_matlab_function+00048455
[  8] 0x000000000505a1ab C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00106923 in_is_matlab_function+00051547
[  9] 0x000000000512684f C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00944207 MathWorks::MException::MExceptionEnvelope::MCOSClassID+00000991
[ 10] 0x00000000051267b1 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00944049 MathWorks::MException::MExceptionEnvelope::MCOSClassID+00000833
[ 11] 0x000000000509da75 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00383605 inGetCurrentWS+00155269
[ 12] 0x000000000509ce8c C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00380556 inGetCurrentWS+00152220
[ 13] 0x000000000509b6e9 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00374505 inGetCurrentWS+00146169
[ 14] 0x0000000004f22694 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_dispatcher.dll+00075412 Mfh_file::dispatch_fh+00000548
[ 15] 0x0000000004f22a7e C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_dispatcher.dll+00076414 Mfunction_handle::dispatch+00000766
[ 16] 0x0000000005059597 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00103831 in_is_matlab_function+00048455
[ 17] 0x000000000505a1ab C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00106923 in_is_matlab_function+00051547
[ 18] 0x000000000512684f C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00944207 MathWorks::MException::MExceptionEnvelope::MCOSClassID+00000991
[ 19] 0x00000000051267b1 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00944049 MathWorks::MException::MExceptionEnvelope::MCOSClassID+00000833
[ 20] 0x000000000509da75 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00383605 inGetCurrentWS+00155269
[ 21] 0x000000000509ce8c C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00380556 inGetCurrentWS+00152220
[ 22] 0x000000000509b6e9 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00374505 inGetCurrentWS+00146169
[ 23] 0x0000000004f22694 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_dispatcher.dll+00075412 Mfh_file::dispatch_fh+00000548
[ 24] 0x0000000004f22a7e C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_dispatcher.dll+00076414 Mfunction_handle::dispatch+00000766
[ 25] 0x0000000005059597 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00103831 in_is_matlab_function+00048455
[ 26] 0x00000000051731a7 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+01257895 inIsKeyword+00027799
[ 27] 0x000000000505b69a C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00112282 in_is_matlab_function+00056906
[ 28] 0x000000000512684f C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00944207 MathWorks::MException::MExceptionEnvelope::MCOSClassID+00000991
[ 29] 0x00000000051267b1 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00944049 MathWorks::MException::MExceptionEnvelope::MCOSClassID+00000833
[ 30] 0x000000000509da75 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00383605 inGetCurrentWS+00155269
[ 31] 0x000000000509ce8c C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00380556 inGetCurrentWS+00152220
[ 32] 0x000000000509b6e9 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00374505 inGetCurrentWS+00146169
[ 33] 0x0000000004f22757 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_dispatcher.dll+00075607 Mfh_file::dispatch_fh+00000743
[ 34] 0x0000000004f22a7e C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_dispatcher.dll+00076414 Mfunction_handle::dispatch+00000766
[ 35] 0x0000000005059597 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00103831 in_is_matlab_function+00048455
[ 36] 0x00000000051731a7 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+01257895 inIsKeyword+00027799
[ 37] 0x000000000505b69a C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00112282 in_is_matlab_function+00056906
[ 38] 0x000000000512684f C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00944207 MathWorks::MException::MExceptionEnvelope::MCOSClassID+00000991
[ 39] 0x00000000051267b1 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00944049 MathWorks::MException::MExceptionEnvelope::MCOSClassID+00000833
[ 40] 0x000000000509da75 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00383605 inGetCurrentWS+00155269
[ 41] 0x000000000509ce8c C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00380556 inGetCurrentWS+00152220
[ 42] 0x000000000509b6e9 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00374505 inGetCurrentWS+00146169
[ 43] 0x0000000004f22757 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_dispatcher.dll+00075607 Mfh_file::dispatch_fh+00000743
[ 44] 0x0000000004f22a7e C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_dispatcher.dll+00076414 Mfunction_handle::dispatch+00000766
[ 45] 0x000000000512b268 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00963176 inAnonymousFunction+00000360
[ 46] 0x000000000512b864 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00964708 inAnonymousFunction+00001892
[ 47] 0x000000000512ba25 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00965157 inAnonymousFunction+00002341
[ 48] 0x000000000512b9f2 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00965106 inAnonymousFunction+00002290
[ 49] 0x000000000512b9a7 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00965031 inAnonymousFunction+00002215
[ 50] 0x00000000050df6bd C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00652989 inGetCallersWorkSpace+00001805
[ 51] 0x00000000050d854d C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00623949 inEvalCmdWithLocalReturn+00000285
[ 52] 0x00000000050d8471 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\m_interpreter.dll+00623729 inEvalCmdWithLocalReturn+00000065
[ 53] 0x00000000fb5fe82d C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\libmwbridge.dll+00059437 mnGetPrompt+00002717
[ 54] 0x00000000fb5ff2a9 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\libmwbridge.dll+00062121 mnParser+00000745
[ 55] 0x00000000fd0e13d4 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\mcr.dll+00398292 mcrInstance::mnParser_on_interpreter_thread+00000036
[ 56] 0x00000000fd0a9757 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\mcr.dll+00169815 mcr::runtime::setInterpreterThreadToCurrent+00019751
[ 57] 0x00000000fd0a9793 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\mcr.dll+00169875 mcr::runtime::setInterpreterThreadToCurrent+00019811
[ 58] 0x00000000fd0a9f91 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\mcr.dll+00171921 mcr::runtime::setInterpreterThreadToCurrent+00021857
[ 59] 0x00000000fab5d216 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\uiw.dll+00512534 UIW_AttachThreadInput+00001270
[ 60] 0x00000000fab5caa5 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\uiw.dll+00510629 wsd_to_MSW+00004373
[ 61] 0x00000000fab5cb29 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\uiw.dll+00510761 wsd_to_MSW+00004505
[ 62] 0x00007ff8ad1708ca                     C:\WINDOWS\system32\USER32.dll+00592074 BroadcastSystemMessageExA+00000586
[ 63] 0x00007ff8ad0e2e1f                     C:\WINDOWS\system32\USER32.dll+00011807 IsWindow+00000367
[ 64] 0x00007ff8ad0e2e96                     C:\WINDOWS\system32\USER32.dll+00011926 IsWindow+00000486
[ 65] 0x00007ff8af413034                      C:\WINDOWS\SYSTEM32\ntdll.dll+00602164 KiUserCallbackDispatcher+00000036
[ 66] 0x00007ff8ad0e2a8a                     C:\WINDOWS\system32\USER32.dll+00010890 PeekMessageW+00000250
[ 67] 0x00007ff8ad0e6283                     C:\WINDOWS\system32\USER32.dll+00025219 GetMessageA+00000243
[ 68] 0x00007ff8ad0e622f                     C:\WINDOWS\system32\USER32.dll+00025135 GetMessageA+00000159
[ 69] 0x00000000fab09bdb C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\uiw.dll+00170971 UIW_ShowMenuItem+00005179
[ 70] 0x00000000fab5db52 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\uiw.dll+00514898 UIW_SuspendAttachThreadInput+00000466
[ 71] 0x0000000100122c83 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\libmwservices.dll+01256579 services::system_events::PpeDispatchHook::dispatchOne+00032291
[ 72] 0x000000010012e6f5 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\libmwservices.dll+01304309 sysq::addProcessPendingEventsUnitTestHook+00005813
[ 73] 0x000000010012e7a0 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\libmwservices.dll+01304480 sysq::addProcessPendingEventsUnitTestHook+00005984
[ 74] 0x0000000100130595 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\libmwservices.dll+01312149 sysq::getCondition+00004629
[ 75] 0x0000000100131f52 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\libmwservices.dll+01318738 svWS_ProcessPendingEvents+00000162
[ 76] 0x00000000fd0aa6ad C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\mcr.dll+00173741 mcr::runtime::setInterpreterThreadToCurrent+00023677
[ 77] 0x00000000fd0ab31a C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\mcr.dll+00176922 mcr::runtime::setInterpreterThreadToCurrent+00026858
[ 78] 0x00000000fd0a2f75 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\mcr.dll+00143221 mcr_process_events+00007557
[ 79] 0x00000000fd0a4882 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\mcr.dll+00149634 mcr_process_events+00013970
[ 80] 0x00000000084ab49d C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\MVMLocal.dll+00177309 mvm_server::inproc::LocalFactory::terminate+00048141
[ 81] 0x00000000fa8fa27a C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\mvm.dll+00828026 mvm::detail::initLocalMvmHack+00000490
[ 82] 0x00000000fa8fa838 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\mvm.dll+00829496 mvm::detail::SessionImpl::privateSession+00000376
[ 83] 0x00000000fa8faa88 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\mvm.dll+00830088 mvm::detail::SessionImpl::privateSession+00000968
[ 84] 0x000000014000630d C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\MATLAB.exe+00025357
[ 85] 0x0000000140007dd0 C:\Program Files\MATLAB\MATLAB Production Server\R2015a\bin\win64\MATLAB.exe+00032208
[ 86] 0x00007ff8acea13d2                   C:\WINDOWS\system32\KERNEL32.DLL+00005074 BaseThreadInitThunk+00000034
[ 87] 0x00007ff8af395444                      C:\WINDOWS\SYSTEM32\ntdll.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.
user191919
  • 724
  • 1
  • 9
  • 27
  • Can you post a snapshot of this "catastrophic error"? It's kind of hard (actually impossible...) to determine what's going wrong if we don't even have any sense of what is happening. – rayryeng Jul 13 '15 at 16:18
  • Just edited the post with it. – user191919 Jul 13 '15 at 16:21
  • Hmm... have you tried stepping through the MEX function with a debugger? http://stackoverflow.com/questions/23714141/preventing-a-mex-file-from-crashing-in-matlab/23714301#23714301 - On the third try, try and step through the MEX code and locate which exact line it's crashing.... and when you do that, update your post so we can see. – rayryeng Jul 13 '15 at 16:24
  • I tried doing the steps for debugging the mex file, but I get loads of `unresolved external` error messages, as in: `glmnetMex.obj : error LNK2019: unresolved external symbol GET_INT_PARMS referenced in function MEXFUNCTION`. – user191919 Jul 13 '15 at 16:45
  • Hmm... does this code come with precompiled MEX files? Did you just use the code straight out of the box or did you compile the code for your platform before running it? Unresolved linking errors come from trying to use code / functions where there is no definition for that code available. – rayryeng Jul 13 '15 at 16:47
  • I had exactly the same issue with some of my own mex files, finally traced it down to a badly declared pointer. It worked on one machine fine, an another with slightly different config it didn't... – srthompers Jul 13 '15 at 16:54
  • It came with precompiled MEX files already. It has mex64 and mex32. You can verify the package at the link given in question, its a quick download if you dont mind. I am using the windows version. – user191919 Jul 13 '15 at 16:54
  • @user191919 - Consider recompiling the MEX files and running the code again. Here are the instructions for that package for 64-bit Windows: http://web.stanford.edu/~hastie/glmnet_matlab/win64compile.html ... also for 32-bit: http://web.stanford.edu/~hastie/glmnet_matlab/win32compile.html – rayryeng Jul 13 '15 at 17:04
  • I cant seem to do the second step. When trying to save the file, options file, it wont allow me (either access denied or the files is open in another program)... – user191919 Jul 13 '15 at 17:17
  • Ok, some progress: I just ignored the second step, recompiled and it seems to be working now normally. Thank you for the help. I'll post if anything new comes up. – user191919 Jul 13 '15 at 17:22
  • yeah the second step you can ignore I believe. That should be handled by later versions of MATLAB. – rayryeng Jul 13 '15 at 17:29
  • OK great. Let me know if it works normally.... if it does, allow me to post this as an answer for you to accept :) – rayryeng Jul 13 '15 at 17:29
  • Yes, please do post as a solution. That was very helpful. – user191919 Jul 13 '15 at 17:50
  • The stack trace indicates that you're running this on MATLAB Production Server, not on MATLAB. Where are you getting this catastrophic error, and what is it you're required to close? MATLAB, or MATLAB Production Server? – Sam Roberts Jul 13 '15 at 20:52
  • @user191919 - Fantastic. Thank you. Doing it now. – rayryeng Jul 13 '15 at 22:34

1 Answers1

1

Summarizing our comments above, first step through the MEX function with a debugger. Check out this post on how to set it up with an IDE based on whatever operating system you're using: Preventing a MEX file from crashing in MATLAB... so on the third try, figure out which line it's crashing at.

Now that you figured out where it's crashing, you're getting Unresolved Link Errors. Unresolved linking errors come from trying to use code / functions where there is no definition for that code available. It sounds like there are precompiled MEX files that are causing the problem when you run the code. Try recompiling the code so that it is most compatible with your system.

The instructions for 64-bit Windows are here: http://web.stanford.edu/~hastie/glmnet_matlab/win64compile.html. Similarly, the 32-bit instructions are here: http://web.stanford.edu/~hastie/glmnet_matlab/win32compile.html. You can skip the second step in the instructions, as I believe that this step is handled by more recent versions of MATLAB.


Hope that will make things more stable!

Community
  • 1
  • 1
rayryeng
  • 102,964
  • 22
  • 184
  • 193