Issue 1:
The script.sparse.linalg module fails to import when running natively on an Apple M1 machine (arm64-apple-darwin). It segfaults while importing the fortran _arpack module. I encountered this while trying to do a density plot in pandas, but it's easy to reproduce separately.

(Thanks for scipy!)

Reproducing code example:

# minimal/most-specific import:
import scipy.sparse.linalg.eigen.arpack._arpack

# more realistic import:
import scipy.sparse.linalg

Error message:

$ python -c 'import scipy.sparse.linalg.eigen.arpack._arpack'
zsh: segmentation fault python -c 'import scipy.sparse.linalg.eigen.arpack._arpack'

Most relevant section of backtrace (from lldb -o run -o bt -- $(pyenv which python) -c 'import scipy.sparse.linalg.eigen.arpack._arpack'):

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xa90257f6a9015ff8)
* frame #0: 0xffffd7f6a9015ff8
frame #1: 0x00000001079f4c80 _arpack.cpython-38-darwin.so`f2pyinitdebug_ + 160
frame #2: 0x00000001079f2e2c _arpack.cpython-38-darwin.so`PyFortranObject_New + 44
frame #3: 0x00000001079eb8b8 _arpack.cpython-38-darwin.so`PyInit__arpack + 888
frame #4: 0x0000000100114f38 python`_PyImport_LoadDynamicModuleWithSpec + 672
frame #5: 0x0000000100114708 python`_imp_create_dynamic + 376
frame #6: 0x00000001000603e0 python`cfunction_vectorcall_FASTCALL + 204
frame #7: 0x000000010002185c python`PyVectorcall_Call + 104
frame #8: 0x00000001000e9ce8 python`_PyEval_EvalFrameDefault + 24848
frame #9: 0x00000001000ed430 python`_PyEval_EvalCodeWithName + 3212
frame #10: 0x0000000100022060 python`_PyFunction_Vectorcall + 248
frame #11: 0x00000001000ec404 python`call_function + 288
frame #12: 0x00000001000e994c python`_PyEval_EvalFrameDefault + 23924
frame #13: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #14: 0x00000001000ec404 python`call_function + 288

Click for full backtrace

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xa90257f6a9015ff8)
* frame #0: 0xffffd7f6a9015ff8
frame #1: 0x00000001079f4c80 _arpack.cpython-38-darwin.so`f2pyinitdebug_ + 160
frame #2: 0x00000001079f2e2c _arpack.cpython-38-darwin.so`PyFortranObject_New + 44
frame #3: 0x00000001079eb8b8 _arpack.cpython-38-darwin.so`PyInit__arpack + 888
frame #4: 0x0000000100114f38 python`_PyImport_LoadDynamicModuleWithSpec + 672
frame #5: 0x0000000100114708 python`_imp_create_dynamic + 376
frame #6: 0x00000001000603e0 python`cfunction_vectorcall_FASTCALL + 204
frame #7: 0x000000010002185c python`PyVectorcall_Call + 104
frame #8: 0x00000001000e9ce8 python`_PyEval_EvalFrameDefault + 24848
frame #9: 0x00000001000ed430 python`_PyEval_EvalCodeWithName + 3212
frame #10: 0x0000000100022060 python`_PyFunction_Vectorcall + 248
frame #11: 0x00000001000ec404 python`call_function + 288
frame #12: 0x00000001000e994c python`_PyEval_EvalFrameDefault + 23924
frame #13: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #14: 0x00000001000ec404 python`call_function + 288
frame #15: 0x00000001000e9930 python`_PyEval_EvalFrameDefault + 23896
frame #16: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #17: 0x00000001000ec404 python`call_function + 288
frame #18: 0x00000001000e99c4 python`_PyEval_EvalFrameDefault + 24044
frame #19: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #20: 0x00000001000ec404 python`call_function + 288
frame #21: 0x00000001000e99c4 python`_PyEval_EvalFrameDefault + 24044
frame #22: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #23: 0x00000001000ec404 python`call_function + 288
frame #24: 0x00000001000e99c4 python`_PyEval_EvalFrameDefault + 24044
frame #25: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #26: 0x0000000100023498 python`object_vacall + 312
frame #27: 0x0000000100023604 python`_PyObject_CallMethodIdObjArgs + 96
frame #28: 0x00000001001134e0 python`PyImport_ImportModuleLevelObject + 1672
frame #29: 0x00000001000dffa4 python`builtin___import__ + 108
frame #30: 0x0000000100021b20 python`cfunction_call_varargs + 140
frame #31: 0x00000001000e9ce8 python`_PyEval_EvalFrameDefault + 24848
frame #32: 0x00000001000ed430 python`_PyEval_EvalCodeWithName + 3212
frame #33: 0x0000000100022060 python`_PyFunction_Vectorcall + 248
frame #34: 0x00000001000ec404 python`call_function + 288
frame #35: 0x00000001000e99c4 python`_PyEval_EvalFrameDefault + 24044
frame #36: 0x00000001000ed430 python`_PyEval_EvalCodeWithName + 3212
frame #37: 0x0000000100022060 python`_PyFunction_Vectorcall + 248
frame #38: 0x0000000100023498 python`object_vacall + 312
frame #39: 0x0000000100023604 python`_PyObject_CallMethodIdObjArgs + 96
frame #40: 0x00000001001135ec python`PyImport_ImportModuleLevelObject + 1940
frame #41: 0x00000001000e83b4 python`_PyEval_EvalFrameDefault + 18396
frame #42: 0x00000001000ed430 python`_PyEval_EvalCodeWithName + 3212
frame #43: 0x00000001000e3b44 python`PyEval_EvalCode + 60
frame #44: 0x00000001000e0f6c python`builtin_exec + 648
frame #45: 0x00000001000603e0 python`cfunction_vectorcall_FASTCALL + 204
frame #46: 0x000000010002185c python`PyVectorcall_Call + 104
frame #47: 0x00000001000e9ce8 python`_PyEval_EvalFrameDefault + 24848
frame #48: 0x00000001000ed430 python`_PyEval_EvalCodeWithName + 3212
frame #49: 0x0000000100022060 python`_PyFunction_Vectorcall + 248
frame #50: 0x00000001000ec404 python`call_function + 288
frame #51: 0x00000001000e994c python`_PyEval_EvalFrameDefault + 23924
frame #52: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #53: 0x00000001000ec404 python`call_function + 288
frame #54: 0x00000001000e9930 python`_PyEval_EvalFrameDefault + 23896
frame #55: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #56: 0x00000001000ec404 python`call_function + 288
frame #57: 0x00000001000e99c4 python`_PyEval_EvalFrameDefault + 24044
frame #58: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #59: 0x00000001000ec404 python`call_function + 288
frame #60: 0x00000001000e99c4 python`_PyEval_EvalFrameDefault + 24044
frame #61: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #62: 0x0000000100023498 python`object_vacall + 312
frame #63: 0x0000000100023604 python`_PyObject_CallMethodIdObjArgs + 96
frame #64: 0x00000001001134e0 python`PyImport_ImportModuleLevelObject + 1672
frame #65: 0x00000001000e83b4 python`_PyEval_EvalFrameDefault + 18396
frame #66: 0x00000001000ed430 python`_PyEval_EvalCodeWithName + 3212
frame #67: 0x00000001000e3b44 python`PyEval_EvalCode + 60
frame #68: 0x00000001000e0f6c python`builtin_exec + 648
frame #69: 0x00000001000603e0 python`cfunction_vectorcall_FASTCALL + 204
frame #70: 0x000000010002185c python`PyVectorcall_Call + 104
frame #71: 0x00000001000e9ce8 python`_PyEval_EvalFrameDefault + 24848
frame #72: 0x00000001000ed430 python`_PyEval_EvalCodeWithName + 3212
frame #73: 0x0000000100022060 python`_PyFunction_Vectorcall + 248
frame #74: 0x00000001000ec404 python`call_function + 288
frame #75: 0x00000001000e994c python`_PyEval_EvalFrameDefault + 23924
frame #76: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #77: 0x00000001000ec404 python`call_function + 288
frame #78: 0x00000001000e9930 python`_PyEval_EvalFrameDefault + 23896
frame #79: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #80: 0x00000001000ec404 python`call_function + 288
frame #81: 0x00000001000e99c4 python`_PyEval_EvalFrameDefault + 24044
frame #82: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #83: 0x00000001000ec404 python`call_function + 288
frame #84: 0x00000001000e99c4 python`_PyEval_EvalFrameDefault + 24044
frame #85: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #86: 0x0000000100023498 python`object_vacall + 312
frame #87: 0x0000000100023604 python`_PyObject_CallMethodIdObjArgs + 96
frame #88: 0x00000001001134e0 python`PyImport_ImportModuleLevelObject + 1672
frame #89: 0x00000001000e83b4 python`_PyEval_EvalFrameDefault + 18396
frame #90: 0x00000001000ed430 python`_PyEval_EvalCodeWithName + 3212
frame #91: 0x00000001000e3b44 python`PyEval_EvalCode + 60
frame #92: 0x00000001000e0f6c python`builtin_exec + 648
frame #93: 0x00000001000603e0 python`cfunction_vectorcall_FASTCALL + 204
frame #94: 0x000000010002185c python`PyVectorcall_Call + 104
frame #95: 0x00000001000e9ce8 python`_PyEval_EvalFrameDefault + 24848
frame #96: 0x00000001000ed430 python`_PyEval_EvalCodeWithName + 3212
frame #97: 0x0000000100022060 python`_PyFunction_Vectorcall + 248
frame #98: 0x00000001000ec404 python`call_function + 288
frame #99: 0x00000001000e994c python`_PyEval_EvalFrameDefault + 23924
frame #100: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #101: 0x00000001000ec404 python`call_function + 288
frame #102: 0x00000001000e9930 python`_PyEval_EvalFrameDefault + 23896
frame #103: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #104: 0x00000001000ec404 python`call_function + 288
frame #105: 0x00000001000e99c4 python`_PyEval_EvalFrameDefault + 24044
frame #106: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #107: 0x00000001000ec404 python`call_function + 288
frame #108: 0x00000001000e99c4 python`_PyEval_EvalFrameDefault + 24044
frame #109: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #110: 0x0000000100023498 python`object_vacall + 312
frame #111: 0x0000000100023604 python`_PyObject_CallMethodIdObjArgs + 96
frame #112: 0x00000001001134e0 python`PyImport_ImportModuleLevelObject + 1672
frame #113: 0x00000001000e83b4 python`_PyEval_EvalFrameDefault + 18396
frame #114: 0x00000001000ed430 python`_PyEval_EvalCodeWithName + 3212
frame #115: 0x00000001000e3b44 python`PyEval_EvalCode + 60
frame #116: 0x00000001000e0f6c python`builtin_exec + 648
frame #117: 0x00000001000603e0 python`cfunction_vectorcall_FASTCALL + 204
frame #118: 0x000000010002185c python`PyVectorcall_Call + 104
frame #119: 0x00000001000e9ce8 python`_PyEval_EvalFrameDefault + 24848
frame #120: 0x00000001000ed430 python`_PyEval_EvalCodeWithName + 3212
frame #121: 0x0000000100022060 python`_PyFunction_Vectorcall + 248
frame #122: 0x00000001000ec404 python`call_function + 288
frame #123: 0x00000001000e994c python`_PyEval_EvalFrameDefault + 23924
frame #124: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #125: 0x00000001000ec404 python`call_function + 288
frame #126: 0x00000001000e9930 python`_PyEval_EvalFrameDefault + 23896
frame #127: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #128: 0x00000001000ec404 python`call_function + 288
frame #129: 0x00000001000e99c4 python`_PyEval_EvalFrameDefault + 24044
frame #130: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #131: 0x00000001000ec404 python`call_function + 288
frame #132: 0x00000001000e99c4 python`_PyEval_EvalFrameDefault + 24044
frame #133: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #134: 0x0000000100023498 python`object_vacall + 312
frame #135: 0x0000000100023604 python`_PyObject_CallMethodIdObjArgs + 96
frame #136: 0x00000001001134e0 python`PyImport_ImportModuleLevelObject + 1672
frame #137: 0x00000001000dffa4 python`builtin___import__ + 108
frame #138: 0x0000000100021b20 python`cfunction_call_varargs + 140
frame #139: 0x00000001000e9ce8 python`_PyEval_EvalFrameDefault + 24848
frame #140: 0x00000001000ed430 python`_PyEval_EvalCodeWithName + 3212
frame #141: 0x0000000100022060 python`_PyFunction_Vectorcall + 248
frame #142: 0x00000001000ec404 python`call_function + 288
frame #143: 0x00000001000e99c4 python`_PyEval_EvalFrameDefault + 24044
frame #144: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #145: 0x00000001000ec404 python`call_function + 288
frame #146: 0x00000001000e99c4 python`_PyEval_EvalFrameDefault + 24044
frame #147: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #148: 0x0000000100023498 python`object_vacall + 312
frame #149: 0x0000000100023604 python`_PyObject_CallMethodIdObjArgs + 96
frame #150: 0x00000001001134e0 python`PyImport_ImportModuleLevelObject + 1672
frame #151: 0x00000001000dffa4 python`builtin___import__ + 108
frame #152: 0x0000000100021b20 python`cfunction_call_varargs + 140
frame #153: 0x00000001000e9ce8 python`_PyEval_EvalFrameDefault + 24848
frame #154: 0x00000001000ed430 python`_PyEval_EvalCodeWithName + 3212
frame #155: 0x0000000100022060 python`_PyFunction_Vectorcall + 248
frame #156: 0x00000001000ec404 python`call_function + 288
frame #157: 0x00000001000e99c4 python`_PyEval_EvalFrameDefault + 24044
frame #158: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #159: 0x00000001000ec404 python`call_function + 288
frame #160: 0x00000001000e99c4 python`_PyEval_EvalFrameDefault + 24044
frame #161: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #162: 0x0000000100023498 python`object_vacall + 312
frame #163: 0x0000000100023604 python`_PyObject_CallMethodIdObjArgs + 96
frame #164: 0x00000001001134e0 python`PyImport_ImportModuleLevelObject + 1672
frame #165: 0x00000001000dffa4 python`builtin___import__ + 108
frame #166: 0x0000000100021b20 python`cfunction_call_varargs + 140
frame #167: 0x00000001000e9ce8 python`_PyEval_EvalFrameDefault + 24848
frame #168: 0x00000001000ed430 python`_PyEval_EvalCodeWithName + 3212
frame #169: 0x0000000100022060 python`_PyFunction_Vectorcall + 248
frame #170: 0x00000001000ec404 python`call_function + 288
frame #171: 0x00000001000e99c4 python`_PyEval_EvalFrameDefault + 24044
frame #172: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #173: 0x00000001000ec404 python`call_function + 288
frame #174: 0x00000001000e99c4 python`_PyEval_EvalFrameDefault + 24044
frame #175: 0x0000000100021ee0 python`function_code_fastcall + 120
frame #176: 0x0000000100023498 python`object_vacall + 312
frame #177: 0x0000000100023604 python`_PyObject_CallMethodIdObjArgs + 96
frame #178: 0x00000001001134e0 python`PyImport_ImportModuleLevelObject + 1672
frame #179: 0x00000001000e83b4 python`_PyEval_EvalFrameDefault + 18396
frame #180: 0x00000001000ed430 python`_PyEval_EvalCodeWithName + 3212
frame #181: 0x00000001000e3b44 python`PyEval_EvalCode + 60
frame #182: 0x0000000100129134 python`PyRun_StringFlags + 244
frame #183: 0x0000000100128fe4 python`PyRun_SimpleStringFlags + 64
frame #184: 0x0000000100145ac8 python`Py_RunMain + 432
frame #185: 0x0000000100146480 python`pymain_main + 340
frame #186: 0x00000001001464fc python`Py_BytesMain + 40
frame #187: 0x000000018e7c8f34 libdyld.dylib`start + 4

Scipy/Numpy/Python version information:

scipy==1.6.0
numpy==1.20.2
python==sys.version_info(major=3, minor=8, micro=7, releaselevel='final', serial=0)

Issue 2:
The fmin_cobyla algorithm can terminate without actually satisfying the constraints.

Indeed, it has a maxcv return value that reports the constraint violation.

See e.g. http://stackoverflow.com/questions/18782092/python-scipy-optimization-issue-fmin-cobyla-one-constraint-is-not-respected http://pastebin.com/gjbeePgt

This is quite surprising behavior, and definitely not adequately documented.

The COBYLA wrappers probably should check the constraint violation, and return with a failed status if it is bigger than some allowed tolerance.