If you are seeing a seg fault during code generation, the recommended action is to contact technical support:
You can try using the generate code only option to codegen to skip the step of the C compiler:
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.