MEX File Segmentation Fault

If a binary MEX file causes a segmentation violation or assertion, it means that the MEX file attempted to access protected, read-only, or unallocated memory.

These types of programming errors can be difficult to track down. Segmentation violations do not always occur at the same point as the logical errors that cause them. If a program writes data to an unintended section of memory, an error might not occur until the program reads and interprets the corrupted data. Therefore, a segmentation violation can occur after the MEX file finishes executing.

One cause of memory corruption is to pass a null pointer to a function. To check for this condition, add code in your MEX file to check for invalid arguments to MEX Library and Matrix API functions.

To troubleshoot problems of this nature, run MATLAB® within a debugging environment.

Related Topics