Why does MATLAB hang or produce a segmentation violation when I use Real-Time Workshop to build a Simulink model which has a Simulink Parameter with a long character array?

2 views (last 30 days)
Why does MATLAB hang or produce a segmentation violation when I use Real-Time Workshop to build a Simulink model which has a Simulink Parameter with a long character array?
I am using a Simulink Parameter in my model, which contains a long character array (>1000 characters). When I build my model, MATLAB will either hang or produce a segmentation violation:
Stack Trace:
[0] libmx.dll:_mxGetNChars(0x2fbbe028, 0x3041d6c8 "[struct('block',['autocode3/Diff..", 3543, 0x2fbbe028) + 42 bytes
[1] libmx.dll:_mxGetString(0, 0x3041d6c8 "[struct('block',['autocode3/Diff..", 3544, 0x2fbbe028) + 70 bytes
[2] simulink.dll:_BdWriteMxArrayProperty(0x00df6c48, 0x2992aad0 "DefnBlocks_AtSource", 0x2fbbe028, 0x00df6c48) + 432 bytes
[3] simulink.dll:struct slErrMsg_tag * __cdecl BdWriteUDDProperties(struct BdWriteInfo_Tag *,class UDInterface *,class UDInterface *,int)(0x00df6c48, 0x2ed79090, 0x2fbbe028, 24) + 913 bytes
[4] simulink.dll:struct slErrMsg_tag * __cdecl BdWriteUDDObjectWithRecursion(struct BdWriteInfo_Tag *,class UDInterface *,int)(0x00df6c48, 0x0ab75a88, 25, 0x00df6ba8 "Àkß") + 188 bytes
[5] simulink.dll:_BdWriteUDDObject(0x00df6c48, 0x2ed79090, 0x00df6bfc, 0) + 18 bytes
[6] simulink.dll:struct slErrMsg_tag * __cdecl WriteModelParameters(struct RTWInfo_tag *)(0x00df6bfc, 0x00df6bfc, 0, 0x2fe4a2d8) + 2500 bytes
[7] simulink.dll:struct slErrMsg_tag * __cdecl WriteRTWFile(struct RTWInfo_tag *)(0x2fe4a2d8, 0x00df6d44 "\mß", 2, 0x7a8a74e8) + 794 bytes
[8] simulink.dll:void __cdecl DoRTWGen(struct RTWInfo_tag *,int,struct mxArray_tag * * const)(0x00df6bfc, 2, 0x00df6d80, 2) + 600 bytes
[9] simulink.dll:_sleRTWGen(2, 0x00df6d80, 9, 0x00df6e48) + 140 bytes

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This bug has been fixed for Release 14 (R14). For previous releases, please read below for any possible workarounds:
This has been verified as a bug in Real-Time Workshop 5.1 (R13SP1) and earlier in the way that Real-Time Workshop handles Simulink parameters with long character strings. There is currently not adequate protection against buffer overflows in the parameters when Real-Time Workshop writes out the ".rtw" file.
Currently, to work around this issue, try using the parameter type "string" instead.

More Answers (0)

Categories

Find more on Simulink Coder in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!