Clear Filters
Clear Filters

MATLAB crashes while running mex function

2 views (last 30 days)
Dhruv Thakkar
Dhruv Thakkar on 13 Apr 2020
Commented: Dhruv Thakkar on 14 Apr 2020
When I try to run a mex function, MATLAB crashes. I first built the fucntion using mex function and then I used the function it gives the following crash report.
Configuration:
Crash Decoding : Disabled - No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : windows-1252
Deployed : false
Graphics Driver : Unknown hardware
Graphics card 1 : Intel Corporation ( 0x8086 ) Intel(R) HD Graphics Family Version 20.19.15.5063 (2018-10-29)
Graphics card 2 : Advanced Micro Devices, Inc. ( 0x1002 ) AMD Radeon R5 M330 Version 15.201.1101.0 (2015-8-6)
Java Version : Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Architecture : win64
MATLAB Entitlement ID : 5847230
MATLAB Root : C:\Program Files\MATLAB\R2019b
MATLAB Version : 9.7.0.1296695 (R2019b) Update 4
OpenGL : hardware
Operating System : Microsoft Windows 10 Home Single Language
Process ID : 30112
Processor ID : x86 Family 6 Model 69 Stepping 1, GenuineIntel
Session Key : b1fe821b-c7e0-4c65-aa1f-7a5dc93ef08e
Window System : Version 10.0 (Build 18363)
Fault Count: 1
Abnormal termination:
Access violation
Register State (from fault):
RAX = 0000000000000018 RBX = 0000000000000fa8
RCX = 00000000000000c0 RDX = 0000000000000f98
RSP = 000000011fe4f1d8 RBP = 0000000000000001
RSI = cdbdf8002c587840 RDI = 0000000146fdf700
R8 = 2e2a9c002c587cc0 R9 = 9d5e630000000060
R10 = 000000011fe4f220 R11 = d81b290000000120
R12 = 00000000000000c0 R13 = 00000000000000c0
R14 = 0000000000000000 R15 = 0000000000000f98
RIP = 00000002dd8921a0 EFL = 00010206
CS = 0033 FS = 0053 GS = 002b
Stack Trace (from fault):
[ 0] 0x00000002dd8921a0 C:\Program Files\MATLAB\R2019b\bin\win64\mkl.dll+25633184 mkl_serv_iface_deallocate+21872336
[ 1] 0x00000002dc419993 C:\Program Files\MATLAB\R2019b\bin\win64\mkl.dll+04168083 mkl_serv_iface_deallocate+00407235
[ 2] 0x00000002dc03bee9 C:\Program Files\MATLAB\R2019b\bin\win64\mkl.dll+00114409
[ 3] 0x00000002dc03addf C:\Program Files\MATLAB\R2019b\bin\win64\mkl.dll+00110047
[ 4] 0x00000002dc042fcc C:\Program Files\MATLAB\R2019b\bin\win64\mkl.dll+00143308
[ 5] 0x00007ffe80dfbf63 C:\Program Files\MATLAB\R2019b\bin\win64\libiomp5md.dll+01097571 _kmp_invoke_microtask+00000147
[ 6] 0x00007ffe80d700c3 C:\Program Files\MATLAB\R2019b\bin\win64\libiomp5md.dll+00524483 _kmp_acquire_nested_drdpa_lock+00033443
[ 7] 0x00007ffe80d6f36e C:\Program Files\MATLAB\R2019b\bin\win64\libiomp5md.dll+00521070 _kmp_acquire_nested_drdpa_lock+00030030
[ 8] 0x00007ffe80db204b C:\Program Files\MATLAB\R2019b\bin\win64\libiomp5md.dll+00794699 _kmp_launch_worker+00000331
[ 9] 0x00007ffeb6137bd4 C:\WINDOWS\System32\KERNEL32.DLL+00097236 BaseThreadInitThunk+00000020
[ 10] 0x00007ffeb628ced1 C:\WINDOWS\SYSTEM32\ntdll.dll+00446161 RtlUserThreadStart+00000033
Can someone please explain what is going on?
  2 Comments
Geoff Hayes
Geoff Hayes on 13 Apr 2020
Dhruv - please post the code for your MEX function and how you are caling it from MATLAB.
Dhruv Thakkar
Dhruv Thakkar on 14 Apr 2020
Hey I'm using the fast_mpc library of Stanford University. I built the function written in C language using the mex as follows.
mex -v fmpc_sim.c -lmwblas -lmwlapack
Also when I run the above mex function I get the following error
Building with 'MinGW64 Compiler (C)'.
C:\ProgramData\MATLAB\SupportPackages\R2019b\3P.instrset\mingw_w64.instrset\bin\gcc -c -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"C:\Program Files\MATLAB\R2019b/extern/include" -I"C:\Program Files\MATLAB\R2019b/simulink/include" -I"C:\Program Files\MATLAB\R2019b/extern\lib\win64\mingw64" -fexceptions -fno-omit-frame-pointer -O2 -fwrapv -DNDEBUG "F:\MP\Matlab\fast_mpc-0.0.1\fmpc_sim.c" -o C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj
C:\ProgramData\MATLAB\SupportPackages\R2019b\3P.instrset\mingw_w64.instrset\bin\gcc -c -DMATLAB_DEFAULT_RELEASE=R2017b -DUSE_MEX_CMD -m64 -DMATLAB_MEX_FILE -I"C:\Program Files\MATLAB\R2019b/extern/include" -I"C:\Program Files\MATLAB\R2019b/simulink/include" -I"C:\Program Files\MATLAB\R2019b/extern\lib\win64\mingw64" -fexceptions -fno-omit-frame-pointer -O2 -fwrapv -DNDEBUG "C:\Program Files\MATLAB\R2019b\extern\version\c_mexapi_version.c" -o C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\c_mexapi_version.obj
C:\ProgramData\MATLAB\SupportPackages\R2019b\3P.instrset\mingw_w64.instrset\bin\gcc -m64 -Wl,--no-undefined -shared -static -s -Wl,"C:\Program Files\MATLAB\R2019b/extern/lib/win64/mingw64/exportsmexfileversion.def" C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\c_mexapi_version.obj -llibmwblas -llibmwlapack -L"C:\Program Files\MATLAB\R2019b\extern\lib\win64\mingw64" -llibmx -llibmex -llibmat -lm -llibmwlapack -llibmwblas -o fmpc_sim.mexw64
Error using mex
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x6ca): undefined reference to
`dposv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x75b): undefined reference to
`dtrtrs_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x79c): undefined reference to
`dtrtrs_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x88b): undefined reference to
`dposv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x917): undefined reference to
`dtrtrs_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x952): undefined reference to
`dtrtrs_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0xa47): undefined reference to
`dgemm_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0xb36): undefined reference to
`dgemm_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0xba5): undefined reference to
`dgemm_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0xc41): undefined reference to
`dposv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0xd17): undefined reference to
`dtrtrs_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0xdb6): undefined reference to
`dgemm_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0xe59): undefined reference to
`dgemm_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0xe91): undefined reference to
`dposv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0xf30): undefined reference to
`dtrsv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0xf61): undefined reference to
`dtrsv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0xfe7): undefined reference to
`dtrsv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x101e): undefined reference to
`dtrsv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1073): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1133): undefined reference to
`dtrsv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1163): undefined reference to
`dtrsv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x11fe): undefined reference to
`dtrsv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1239): undefined reference to
`dtrsv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1283): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1329): undefined reference to
`dtrsv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x135d): undefined reference to
`dtrsv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x13a3): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1481): undefined reference to
`dtrsv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1552): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1597): undefined reference to
`dtrsv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1648): undefined reference to
`dtrsv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1714): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1755): undefined reference to
`dtrsv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x17e9): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1885): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1912): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1a2c): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1aca): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1c43): undefined reference to
`dposv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1c9f): undefined reference to
`dposv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1d94): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1e5c): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1eaf): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1f56): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x1ff7): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x2061): more undefined
references to `dgemv_' follow
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x214b): undefined reference to
`daxpy_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x232f): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x2380): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x23ec): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x243d): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x24b9): undefined reference to
`dnrm2_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x24d0): undefined reference to
`dnrm2_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x27e3): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x37a0): undefined reference to
`dgemm_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x381e): undefined reference to
`dgemm_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x3a73): undefined reference to
`dgemm_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x3add): undefined reference to
`dgemm_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x3b51): undefined reference to
`dgemm_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x3bc1): more undefined
references to `dgemm_' follow
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x3c49): undefined reference to
`dposv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x3f84): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x3fe3): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x400a): undefined reference to
`daxpy_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x4044): undefined reference to
`daxpy_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x4134): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x41a9): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x4208): undefined reference to
`dgemv_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x422f): undefined reference to
`daxpy_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x4514): undefined reference to
`dgemm_'
C:\Users\Hp\AppData\Local\Temp\mex_761708957171290_29064\fmpc_sim.obj:fmpc_sim.c:(.text+0x4592): undefined reference to
`dgemm_'
collect2.exe: error: ld returned 1 exit status

Sign in to comment.

Answers (0)

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!