- Double-check your code
- Make sure that there aren’t any declarations that might be using too much memory.
This is also a useful tip if you’re getting Segmentation fault: 11 while using Python.
3. Use the malloc command


- Use the malloc command properly.
- Of course, always use the following command to free the memory:
free()
4. Use the char var/int arr command


In your code, use the following command:
char var[strlen(x)+1]
int arr[(sizeof(x)/sizeof(x[0]) +1)]
Use one of these commands depending on your needs.
5. Other general tips


- Make sure that your global variables have assigned values.
- Separate your code into different files for easier debugging.
Segmentation fault 11 Python
1. Uninstall Shapely


On your Mac, run the following command:
pip uninstall shapely; pip install --no-binary :all: shapely
Keep in mind that this method might only work if you’re trying to install Cartopy.
2. Use the Terminal
- Start the Terminal from the Applications > Utilities directory.
- Once the Terminal starts, run the following commands:
cd /Library/Frameworks/Python.framework/Versions/3.3
cd ./lib/python3.3/lib-dynload
sudo mv readline.so readline.so.disabled
Segmentation fault 11 is usually caused by memory allocation issues, and if you’re having this problem, be sure to try some of the solutions mentioned above.
This post was written by Milan Stanojevic and was first posted to WindowsReport