MATLAB Answers

MATLAB Crashing while simulating C MEX S functions with Structure with array data members.

2 views (last 30 days)
The MATLAB is crashing while doing simulation in Simulink. The simulation contains mex files generated using s-function builder. The mex file named “Park_Transformation2020_1109.mexw64’ which is mentioned in crash report have structures with member functions along with array data members. Please find the details below:
MATLAB Version: 9.6.0.1072779 (R2019a)
Description
Faulting Application Path: E:\programs\Matlab 2019\bin\win64\MATLAB.exe
Problem signature
Problem Event Name: APPCRASH
Application Name: MATLAB.exe
Application Version: 9.6.0.0
Application Timestamp: 5c6f0290
Fault Module Name: StackHash_1d6e
Fault Module Version: 10.0.17763.348
Fault Module Timestamp: ca65c822
Exception Code: c0000374
Exception Offset: PCH_4C_FROM_ntdll+0x00000000000A01C4
OS Version: 10.0.17763.2.0.0.256.4
Locale ID: 16393
Additional Information 1: 1d6e
Additional Information 2: 1d6e4d0ba5eff152f1e6046ac6551dcd
Additional Information 3: f2e4
Additional Information 4: f2e42e7359e582bdb9f607fad637f025
Extra information about the problem
Bucket ID: 25b002f9645a785bbf5d83e99484edd8 (2260107627252215256)
#################################Crash Report###################################################
MATLAB crash file:C:\Users\VARNA~1.SEB\AppData\Local\Temp\matlab_crash_dump.99192-1:
-------------------------------------------------------------------------------
Access violation detected at Tue Nov 10 03:51:32 2020 +0530
--------------------------------------------------------------------------------
Configuration:
Crash Decoding : Disabled - No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : windows-1252
Deployed : false
Graphics Driver : Intel Intel(R) HD Graphics 520 Version 4.5.0 - Build 26.20.100.7757
Graphics card 1 : Intel Corporation ( 0x8086 ) Intel(R) HD Graphics 520 Version 26.20.100.7757 (2020-1-9)
Java Version : Java 1.8.0_181-b13 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Architecture : win64
MATLAB Entitlement ID : 2097855
MATLAB Root : E:\programs\Matlab 2019
MATLAB Version : 9.6.0.1072779 (R2019a)
OpenGL : hardware
Operating System : Microsoft Windows 10 Enterprise
Process ID : 99192
Processor ID : x86 Family 6 Model 78 Stepping 3, GenuineIntel
Session Key : a4e812ce-e86c-46c4-9451-4946f5dd674c
Window System : Version 10.0 (Build 17763)
Fault Count: 1
Abnormal termination:
Access violation
Register State (from fault):
RAX = 00000002e785a090 RBX = 00000002e7859f88
RCX = 0000000030da9fc0 RDX = 0000000031ba21b0
RSP = 00000000043f9728 RBP = 00000000043f97b0
RSI = 00000002e7859f80 RDI = 00000002e7859f78
R8 = 00000002e7859fa8 R9 = 00000002e7859fa0
R10 = 00000002e7859f98 R11 = 00000002e7859f90
R12 = 00000002e7859f70 R13 = 00000002e7859f68
R14 = 00000002e7859f60 R15 = 00000002e785a0a8
RIP = 00000000403e7cec EFL = 00010206
CS = 0033 FS = 0053 GS = 002b
Stack Trace (from fault):
[ 0] 0x00000000403e7cec <unknown-module>+00000000
[ 1] 0x0000000030da1bdb E:\MATLAB\STATCOM\Park_Transformation2020_1109.mexw64+00007131
[ 2] 0x0000000161174861 bin\win64\libmwsimulink.dll+18106465 slSetStateflowChartStateAccessInterface+00214945
[ 3] 0x0000000161173aa2 bin\win64\libmwsimulink.dll+18102946 slSetStateflowChartStateAccessInterface+00211426
[ 4] 0x0000000161170f7c bin\win64\libmwsimulink.dll+18091900 slSetStateflowChartStateAccessInterface+00200380
[ 5] 0x0000000161176783 bin\win64\libmwsimulink.dll+18114435 slSetStateflowChartStateAccessInterface+00222915
[ 6] 0x00000001611443eb bin\win64\libmwsimulink.dll+17908715 slSetStateflowChartStateAccessInterface+00017195
[ 7] 0x0000000162f33f50 bin\win64\sl_engine_classes.dll+03096400 ExecSystem::ResetExecSystemSchemeForSignalVal+00009584
[ 8] 0x0000000160a1f33c bin\win64\libmwsimulink.dll+10416956 slAccRegPrmChangeFcn+00057020
[ 9] 0x0000000160ada16a bin\win64\libmwsimulink.dll+11182442 sl_pir::copyContentBetweenModels+00055370
[ 10] 0x0000000161214b32 bin\win64\libmwsimulink.dll+18762546 SLGlue::PortSignalGenerator::isEmpty+00437154
[ 11] 0x00000001612149fc bin\win64\libmwsimulink.dll+18762236 SLGlue::PortSignalGenerator::isEmpty+00436844
[ 12] 0x000000013c0a5186 bin\win64\libmwslexec_runtime.dll+00479622 slexec::runtime::sim::ExecutionHelper::serialize+00059142
[ 13] 0x000000013c0829bd bin\win64\libmwslexec_runtime.dll+00338365 slexec::runtime::engine::ExecutionEngine::step+00000029
[ 14] 0x00000001611c784b bin\win64\libmwsimulink.dll+18446411 SLGlue::PortSignalGenerator::isEmpty+00121019
[ 15] 0x00000001611b4405 bin\win64\libmwsimulink.dll+18367493 SLGlue::PortSignalGenerator::isEmpty+00042101
[ 16] 0x00000001611b4069 bin\win64\libmwsimulink.dll+18366569 SLGlue::PortSignalGenerator::isEmpty+00041177
[ 17] 0x00000001611ad330 bin\win64\libmwsimulink.dll+18338608 SLGlue::PortSignalGenerator::isEmpty+00013216
[ 18] 0x00000001611a5638 bin\win64\libmwsimulink.dll+18306616 slstSetOutputPortRateID+00125544
[ 19] 0x00000001611a036a bin\win64\libmwsimulink.dll+18285418 slstSetOutputPortRateID+00104346
[ 20] 0x00000001611a6834 bin\win64\libmwsimulink.dll+18311220 slstSetOutputPortRateID+00130148
[ 21] 0x00000000fd0264de bin\win64\iqm.dll+00615646 iqm::PackagedTaskPlugin::execute+00000894
[ 22] 0x00000000fd026353 bin\win64\iqm.dll+00615251 iqm::PackagedTaskPlugin::execute+00000499
[ 23] 0x0000000017340d9b bin\win64\mcr.dll+00527771 mcr::runtime::setInterpreterThreadSingletonToCurrent+00185467
[ 24] 0x00000000fd004c27 bin\win64\iqm.dll+00478247 iqm::Iqm::setupIqmFcnPtrs+00088327
[ 25] 0x00000000fd004c79 bin\win64\iqm.dll+00478329 iqm::Iqm::setupIqmFcnPtrs+00088409
[ 26] 0x00000000fd004a27 bin\win64\iqm.dll+00477735 iqm::Iqm::setupIqmFcnPtrs+00087815
[ 27] 0x00000000fcfdd61e bin\win64\iqm.dll+00316958 iqm::Iqm::create+00005198
[ 28] 0x00000000fb5fe917 bin\win64\libmwbridge.dll+00059671 ioReadLine+00000887
[ 29] 0x00000000fb5fe6ca bin\win64\libmwbridge.dll+00059082 ioReadLine+00000298
[ 30] 0x00000000fb60f61b bin\win64\libmwbridge.dll+00128539 mnDebugPrompt+00002155
[ 31] 0x00000000fb60eee5 bin\win64\libmwbridge.dll+00126693 mnDebugPrompt+00000309
[ 32] 0x00000000fb60f990 bin\win64\libmwbridge.dll+00129424 mnParser+00000592
[ 33] 0x0000000017399818 bin\win64\mcr.dll+00890904 mcrInstance::releaseThread+00002552
[ 34] 0x00000000172dc34a bin\win64\mcr.dll+00115530 mcrOptions::set_use_license_manager+00080250
[ 35] 0x00000000172fa324 bin\win64\mcr.dll+00238372 mcrOptions::set_use_license_manager+00203092
[ 36] 0x00000000fd0264de bin\win64\iqm.dll+00615646 iqm::PackagedTaskPlugin::execute+00000894
[ 37] 0x00000000fd026353 bin\win64\iqm.dll+00615251 iqm::PackagedTaskPlugin::execute+00000499
[ 38] 0x0000000017340d9b bin\win64\mcr.dll+00527771 mcr::runtime::setInterpreterThreadSingletonToCurrent+00185467
[ 39] 0x00000000fd004c27 bin\win64\iqm.dll+00478247 iqm::Iqm::setupIqmFcnPtrs+00088327
[ 40] 0x00000000fd004c79 bin\win64\iqm.dll+00478329 iqm::Iqm::setupIqmFcnPtrs+00088409
[ 41] 0x00000000fd004a27 bin\win64\iqm.dll+00477735 iqm::Iqm::setupIqmFcnPtrs+00087815
[ 42] 0x00000000fcfde61a bin\win64\iqm.dll+00321050 iqm::Iqm::create+00009290
[ 43] 0x00000000fcfddd9f bin\win64\iqm.dll+00318879 iqm::Iqm::create+00007119
[ 44] 0x000000001731e593 bin\win64\mcr.dll+00386451 mcr::runtime::setInterpreterThreadSingletonToCurrent+00044147
[ 45] 0x000000001731eb9f bin\win64\mcr.dll+00387999 mcr::runtime::setInterpreterThreadSingletonToCurrent+00045695
[ 46] 0x000000001731d9fc bin\win64\mcr.dll+00383484 mcr::runtime::setInterpreterThreadSingletonToCurrent+00041180
[ 47] 0x00000000173de67c bin\win64\mcr.dll+01173116 mcr::mvm::detail::activateMcr+00016076
[ 48] 0x000000001720f951 bin\win64\MVMLocal.dll+00391505 mvm_server::inproc::LocalFactory::terminate+00186993
[ 49] 0x00000000fa9e15e0 bin\win64\mvm.dll+01775072 mvm::detail::SessionImpl::initWithOptions+00000592
[ 50] 0x00000000fa9e22a0 bin\win64\mvm.dll+01778336 mvm::detail::SessionImpl::runMain+00000128
[ 51] 0x00000000fa9e24cc bin\win64\mvm.dll+01778892 mvm::detail::SessionImpl::runMatlabDesktop+00000268
[ 52] 0x0000000140007016 bin\win64\MATLAB.exe+00028694 mwboost::serialization::singleton_module::unlock+00000950
[ 53] 0x0000000140007eeb bin\win64\MATLAB.exe+00032491 mwboost::serialization::singleton_module::unlock+00004747
[ 54] 0x00007ffef42481f4 C:\WINDOWS\System32\KERNEL32.DLL+00098804 BaseThreadInitThunk+00000020
[ 55] 0x00007ffef44ba251 C:\WINDOWS\SYSTEM32\ntdll.dll+00434769 RtlUserThreadStart+00000033
Program State:
Most Recent Simulink Activity:
Create Segment : OK in editor 1 at Tue Nov 10 15:50:07 2020
Create Segment : OK in editor 1 at Tue Nov 10 15:50:05 2020
Create Segment : OK in editor 1 at Tue Nov 10 15:50:04 2020
Create Segment : OK in editor 1 at Tue Nov 10 15:50:00 2020
Create Segment : OK in editor 1 at Tue Nov 10 15:49:58 2020
Create Segment : OK in editor 1 at Tue Nov 10 15:49:57 2020
Create Segment : OK in editor 1 at Tue Nov 10 15:49:54 2020
Create Segment : OK in editor 1 at Tue Nov 10 15:49:49 2020
Create Segment : OK in editor 1 at Tue Nov 10 15:49:47 2020
Create Segment : OK in editor 1 at Tue Nov 10 15:49:45 2020
Most Recent Tool Interaction:
Editor 1: tools idle, class Simulink::SegmentCreationTool is most recently active tool since Tue Nov 10 15:50:07 2020

Accepted Answer

Mark McBroom
Mark McBroom on 14 Nov 2020
These types of errors are best resolved by using a debugger to step through the generated code. In the S-Function Builder GUI, select the arrow beneath the "Build" button and check the "create a debuggable MEX-file".
Then, follow these instructions for using a source code debugger to set break points and step through the code until you find the error.
If you are not comfortable using a source code debugger, you could try adding mexPrintf() statements to your C code.
Thanks
Mark.

More Answers (0)

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!