MATLAB: Does a segmentation fault occur when I run a model which contains an S-function generated by S-function Target in Real-Time Workshop

codecrashgenerations-functionsegsimulink codertargetvio

When I run the model, I experience a segmentation fault similar to:
-----------------
Segmentation violation detected at Wed Feb 18 12:52:31 2004
-----------------
Configuration:
MATLAB Version: 6.5.1.199709 (R13) Service Pack 1
Operating System: Microsoft Windows 2000
Window System:Version 5.0 (Build 2195: Service Pack 3)
Processor ID: x86 Family 6 Model 8 Stepping 6, GenuineIntel
Virtual Machine:Java 1.3.1_01 with Sun Microsystems Inc. Java HotSpot(TM) Client VM
(mixed mode)
Register State:
EAX = 2d4cdb08EBX = 2d400fe8
ECX = 22fd8aa8EDX = 00000000
ESI = 22fcbb50EDI = 00000004
EBP = 00df9064ESP = 00df9064
EIP = 454e1645FLG = 00010206
Stack Trace:
[0] testsub_sf.dll:0x454e1645(0x2d250ac8, 0x00df908c, 0x7afa2447, 0xfffffffe)
[1] testsub_sf.dll:0x454e14ce(0xfffffffe, 0x2d40a860, 4, 0x23908390)
[2] libmex.dll:_mexRunMexFile(0xfffffffe, 0x2d40a860, 4, 0x23908390) + 71 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 *)(0xfffffffe, 0x2d40a860, 4, 0x23908390) + 476 bytes
[4] m_interpreter.dll:void __cdecl inRunMexFile(int,struct mxArray_tag * * const,
int,struct mxArray_tag * * const,struct mexfiles *)(0xfffffffe, 0x2d40a860, 4, 0x23908390) + 126 bytes
[5] m_interpreter.dll:void __cdecl inCallMexFile(int,struct mxArray_tag * * const,int,
struct mxArray_tag * * const,struct MATLAB_Function_tag *,bool)
(0xfffffffe, 0x2d40a860, 4, 0x23908390) + 28 bytes
[snip]
This appears to be related to code generated from a linked library block containing a Stateflow chart.

Best Answer

This bug has been fixed in Release 14 Service Pack 2 (R14SP2). For previous releases, please read below for any possible workarounds:
This has been verified as a bug in Real-Time Workshop in the way that code is generated for the S-function Target.
Currently, to work around this issue, break all library links before generating code for S-function Target.