MATLAB seg fault during codegen

2 views (last 30 days)
Chuck37
Chuck37 on 24 Oct 2014
Edited: Ryan Livingston on 24 Oct 2014
It's not unusual for codegen to generate code that will seg fault, but I now have a case where I get a seg fault during codegen operation (could be the compiler? I'm not sure how to tell). It comes and goes depending on whether I add a particular argument to the function, which is a simple vector input. Any ideas what to look for? I'm generating mex by the way, on linux.

Accepted Answer

Ryan Livingston
Ryan Livingston on 24 Oct 2014
Edited: Ryan Livingston on 24 Oct 2014
If you are seeing a seg fault during code generation, the recommended action is to contact technical support:
for assistance.
You can try using the generate code only option to codegen to skip the step of the C compiler:
codegen foo -args {1} -c
That flag causes the code to be generated but not compiled. It corresponds to the GenCodeOnly option on a config object returned from coder.config:
As regards seg faults in the generated code, the most common cause of generated code that behaves unexpectedly is the usage of constructs which are not supported for code generation. Growing arrays by indexing an example of such a construct.
Typically, when such misbehaviors are seen, if a MEX function were to be generated and executed with the same inputs, a runtime error will occur that alerts the user to the presence of a construct in the source MATLAB code that is erroneous for code generation.
The next thing to investigate if there are seg faults when running the generated MEX would be any calls to external C code using coder.ceval.
If the generated MEX is not issuing an error, the coder.ceval calls are proper and seg faults are still seen, you could post a MATLAB example that reproduces it. Also, reporting to MathWorks Technical Support so the issue may be investigated is a good idea.

More Answers (0)

Tags

Products

Community Treasure Hunt

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

Start Hunting!