Matthew
unread,Feb 13, 2015, 7:31:53 PM2/13/15You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
I'm using tunable inline parameters and Rapid Simulation Target with my simulink model in R2014b. My model compiles and runs without error if I don't pass inline parameters using the rtP structure, but I get a segmentation fault when I do. I have other models that compile and run without a problem so I expect there is something about this slx file in particular.
Here is error message in gdb:
Program received signal SIGSEGV, Segmentation fault.
0x00000000004222aa in ReplaceRtP (S=0x1100a20, paramStructure=0x1102720)
at /usc-data/m/linux/matlabR2014b/rtw/c/src/rapid/rapid_utils.c:1476
1476 char *transAddress = dtTransGetAddress(dtTable, dataTransIdx);
Missing separate debuginfos, use: debuginfo-install libX11-1.6.0-2.2.el6.x86_64 libXau-1.0.6-4.el6.x86_64 libxcb-1.9.1-2.el6.x86_64 ncurses-libs-5.7-3.20090208.el6.x86_64 zlib-1.2.3-29.el6.x86_64
(gdb) where
#0 0x00000000004222aa in ReplaceRtP (S=0x1100a20, paramStructure=0x1102720)
at /usc-data/m/linux/matlabR2014b/rtw/c/src/rapid/rapid_utils.c:1476
#1 0x0000000000423989 in rt_RapidReadMatFileAndUpdateParams (S=0x1100a20)
at /usc-data/m/linux/matlabR2014b/rtw/c/src/rapid/rapid_utils.c:2103
#2 0x000000000041d264 in main (argc=3, argv=0x7fffffffc058)
at /usc-data/m/linux/matlabR2014b/rtw/c/rsim/rsim_main.c:644
(gdb) p dtTable
$13 = (DataTypeTransitionTable *) 0x1100a00
(gdb) p dataTransIdx
$14 = 0
I have only one tunable variable. It is designated as a SimulinkGlobal in the Model Parameter Configuration dialog window. Indeed, when I retrieve the rtP structure using rsimgetrtp, the structure contains the map field and the data values are as I set them in the workspace. Here are the contents:
>> rtP
rtP =
modelChecksum: [4.1022e+09 58414328 2.2901e+09 979637131]
parameters: [1x1 struct]
>> rtP.parameters
ans =
dataTypeName: 'double'
dataTypeId: 0
complex: 0
dtTransIdx: 0
values: [1x98 double]
map: [1x1 struct]
>> rtP.parameters.map
ans =
Identifier: 'i_init'
ValueIndices: [1 98]
Dimensions: [98 1]
>> rtP.parameters.values(1)
ans =
865.1175
I pass the rtP structure in to my executable correctly since I see the correct filename when debugging in rapid_utils.c. rt_ReadParamStructMatFile appears to be reading the values correctly at rapid_utils.c:325. I do get a good pointer there and I retrieve the correct number of elements and values:
325 dtprmInfo->rVals = mxGetData(mat);
(gdb) p dtprmInfo->nEls
$2 = 98
(gdb) n
326 dtprmInfo->iVals = mxGetImagData(mat);
(gdb) p dtprmInfo->rVals
$3 = (void *) 0x1680b40
(gdb) p ((double *)dtprmInfo->rVals)[0]
$11 = 865.11753589911314
In ReplaceRtP, paramStructure is still good:
(gdb) where
#0 0x00000000004222aa in ReplaceRtP (S=0x1100a20, paramStructure=0x1102720)
at /usc-data/m/linux/matlabR2014b/rtw/c/src/rapid/rapid_utils.c:1476
#1 0x0000000000423989 in rt_RapidReadMatFileAndUpdateParams (S=0x1100a20)
at /usc-data/m/linux/matlabR2014b/rtw/c/src/rapid/rapid_utils.c:2103
#2 0x000000000041d264 in main (argc=3, argv=0x7fffffffc058)
at /usc-data/m/linux/matlabR2014b/rtw/c/rsim/rsim_main.c:644
(gdb) p *(double *)paramStructure.dtParamInfo.rVals
$20 = 865.11753589911314
For some reason, dtTransGetAddress fails:
char *transAddress = dtTransGetAddress(dtTable, dataTransIdx);
In rtw/c/src/dt_info.h:
#define dtTransGetAddress(dtTable, idx) \
((dtTable)->transitions[(idx)].baseAddr)
I get:
(gdb) p *dtTable
$22 = {numTransitions = 0, transitions = 0x0}
So transitions is null. This is the problem. Why?
In rapid_utils.c:1471:
DataTypeTransitionTable *dtTable = dtGetParamDataTypeTrans(dtInfo);
In dt_info.h:78:
#define dtGetParamDataTypeTrans(dtInfo) ((dtInfo)->P)
I get:
(gdb) p *dtInfo
$24 = {numDataTypes = 0, dataTypeSizes = 0x0, dataTypeNames = 0x42e740, B = 0x10ff640,
P = 0x1100a00, DWork = 0x42e780, Xd = 0x100000000, U = 0x0, Y = 0x16840f0}
(gdb) p *dtInfo.P
$25 = {numTransitions = 0, transitions = 0x0}
Chasing it further to rapid_utils.c:1470:
const DataTypeTransInfo *dtInfo = (const DataTypeTransInfo *)ssGetModelMappingInfo(S);
So ssGetModelMappingInfo must be failing to retrieve P but I can't find the source for ssGetModelMappingInfo to figure out why.
Any suggestions? Any settings in the slx file that I should double check? I've compared my settings to other slx files that work fine in 2014b and could not find a discrepancy.