psycopg / psycopg2

PostgreSQL database adapter for the Python programming language
https://www.psycopg.org/
Other
3.31k stars 503 forks source link

malloc: double free on Mac M1 #1697

Closed DSLituiev closed 3 months ago

DSLituiev commented 3 months ago

Versions:

Describe the bug Upon psycopg2.connect,

python(46885,0x203d8fac0) malloc: double free for ptr 0x1243fd200
python(46885,0x203d8fac0) malloc: *** set a breakpoint in malloc_error_break to debug
Abort trap: 6
dvarrazzo commented 3 months ago

Did you upgrade the system recently and have a mix of new and old libraries?

Can we have more information? Such as:

dvarrazzo commented 3 months ago

Not enough info. Probably caused by some buggy macOS library.

nrodnova commented 2 months ago

@DSLituiev were you able to resolve the error? We are experiencing the same issue.

dvarrazzo commented 2 months ago

@nrodnova Any chance to have a core dump to debug it?

nrodnova commented 2 months ago

@dvarrazzo Unfortunately, no. My colleague had this problem, and he fixed it by now - by cleaning up his environment and reinstalling latest versions of everything. We use Python 3.10. If I find out more, I will post here.

nickodell commented 1 month ago

Any chance to have a core dump to debug it?

I'm having a similar problem, and I have a core dump.

I get the following error message:

$ python manage.py migrate           
[...]
python(41275,0x7ff8566c37c0) malloc: double free for ptr 0x7faeb0a4c600
python(41275,0x7ff8566c37c0) malloc: *** set a breakpoint in malloc_error_break to debug
[1]    41275 abort (core dumped)  python manage.py migrate

Investingating the core dump, it crashes with the following backtrace:

$ lldb python --core /cores/core.41275
(lldb) target create "python" --core "/cores/core.41275"
Core file '/cores/core.41275' (x86_64) was loaded.
(lldb) bt
* thread #1
  * frame #0: 0x00007ff812faf196 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007ff812fe6ee6 libsystem_pthread.dylib`pthread_kill + 263
    frame #2: 0x00007ff812f0db45 libsystem_c.dylib`abort + 123
    frame #3: 0x00007ff812e24752 libsystem_malloc.dylib`malloc_vreport + 888
    frame #4: 0x00007ff812e39a08 libsystem_malloc.dylib`malloc_zone_error + 183
    frame #5: 0x000000010b7174ee libpq.5.14.dylib`freePGconn + 1031
    frame #6: 0x000000010b6c9a33 _psycopg.cpython-310-darwin.so`conn_close + 83
    frame #7: 0x000000010b6ca568 _psycopg.cpython-310-darwin.so`connection_dealloc + 40
    frame #8: 0x0000000107ff42ad libpython3.10.dylib`type_call + 397
    frame #9: 0x0000000107f982e5 libpython3.10.dylib`_PyObject_MakeTpCall + 373
    frame #10: 0x0000000107f98f45 libpython3.10.dylib`_PyObject_CallFunctionVa + 709
    frame #11: 0x0000000107f99166 libpython3.10.dylib`_PyObject_CallFunction_SizeT + 166
    frame #12: 0x000000010b6d7475 _psycopg.cpython-310-darwin.so`psyco_connect + 213
    frame #13: 0x0000000107fdc295 libpython3.10.dylib`cfunction_call + 69
    frame #14: 0x0000000107f987fc libpython3.10.dylib`_PyObject_Call + 140
    frame #15: 0x0000000108073326 libpython3.10.dylib`_PyEval_EvalFrameDefault + 25942
    frame #16: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #17: 0x0000000107f986ab libpython3.10.dylib`PyVectorcall_Call + 155
    frame #18: 0x0000000108073326 libpython3.10.dylib`_PyEval_EvalFrameDefault + 25942
    frame #19: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #20: 0x0000000108073326 libpython3.10.dylib`_PyEval_EvalFrameDefault + 25942
    frame #21: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #22: 0x00000001080769bc libpython3.10.dylib`call_function + 428
    frame #23: 0x0000000108072e95 libpython3.10.dylib`_PyEval_EvalFrameDefault + 24773
    frame #24: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #25: 0x0000000108073326 libpython3.10.dylib`_PyEval_EvalFrameDefault + 25942
    frame #26: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #27: 0x00000001080769bc libpython3.10.dylib`call_function + 428
    frame #28: 0x0000000108072e95 libpython3.10.dylib`_PyEval_EvalFrameDefault + 24773
    frame #29: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #30: 0x0000000108073326 libpython3.10.dylib`_PyEval_EvalFrameDefault + 25942
    frame #31: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #32: 0x00000001080769bc libpython3.10.dylib`call_function + 428
    frame #33: 0x0000000108072e95 libpython3.10.dylib`_PyEval_EvalFrameDefault + 24773
    frame #34: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #35: 0x00000001080769bc libpython3.10.dylib`call_function + 428
    frame #36: 0x0000000108072e95 libpython3.10.dylib`_PyEval_EvalFrameDefault + 24773
    frame #37: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #38: 0x0000000108073326 libpython3.10.dylib`_PyEval_EvalFrameDefault + 25942
    frame #39: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #40: 0x00000001080769bc libpython3.10.dylib`call_function + 428
    frame #41: 0x0000000108072e95 libpython3.10.dylib`_PyEval_EvalFrameDefault + 24773
    frame #42: 0x0000000107facf8f libpython3.10.dylib`gen_send_ex2 + 431
    frame #43: 0x0000000107fac016 libpython3.10.dylib`gen_iternext + 22
    frame #44: 0x000000010806a608 libpython3.10.dylib`builtin_next + 88
    frame #45: 0x0000000107fdbb95 libpython3.10.dylib`cfunction_vectorcall_FASTCALL + 197
    frame #46: 0x00000001080769bc libpython3.10.dylib`call_function + 428
    frame #47: 0x000000010806d3e2 libpython3.10.dylib`_PyEval_EvalFrameDefault + 1554
    frame #48: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #49: 0x0000000107f9accf libpython3.10.dylib`method_vectorcall + 479
    frame #50: 0x0000000108072c73 libpython3.10.dylib`_PyEval_EvalFrameDefault + 24227
    frame #51: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #52: 0x00000001080769bc libpython3.10.dylib`call_function + 428
    frame #53: 0x0000000108072ec1 libpython3.10.dylib`_PyEval_EvalFrameDefault + 24817
    frame #54: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #55: 0x0000000107f99c51 libpython3.10.dylib`object_vacall + 353
    frame #56: 0x0000000107f99fb6 libpython3.10.dylib`PyObject_CallFunctionObjArgs + 166
    frame #57: 0x0000000107fe020e libpython3.10.dylib`_PyObject_GenericGetAttrWithDict + 494
    frame #58: 0x0000000107fdf9d5 libpython3.10.dylib`PyObject_GetAttr + 85
    frame #59: 0x0000000108071253 libpython3.10.dylib`_PyEval_EvalFrameDefault + 17539
    frame #60: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #61: 0x00000001080769bc libpython3.10.dylib`call_function + 428
    frame #62: 0x0000000108072ec1 libpython3.10.dylib`_PyEval_EvalFrameDefault + 24817
    frame #63: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #64: 0x0000000107f99c51 libpython3.10.dylib`object_vacall + 353
    frame #65: 0x0000000107f99fb6 libpython3.10.dylib`PyObject_CallFunctionObjArgs + 166
    frame #66: 0x0000000107fe020e libpython3.10.dylib`_PyObject_GenericGetAttrWithDict + 494
    frame #67: 0x0000000107fdf9d5 libpython3.10.dylib`PyObject_GetAttr + 85
    frame #68: 0x0000000108101d8e libpython3.10.dylib`attrgetter_call + 142
    frame #69: 0x0000000107f982e5 libpython3.10.dylib`_PyObject_MakeTpCall + 373
    frame #70: 0x0000000107fa26f7 libpython3.10.dylib`property_descr_get + 183
    frame #71: 0x0000000107fe00dd libpython3.10.dylib`_PyObject_GenericGetAttrWithDict + 189
    frame #72: 0x0000000107fdf9d5 libpython3.10.dylib`PyObject_GetAttr + 85
    frame #73: 0x0000000108071253 libpython3.10.dylib`_PyEval_EvalFrameDefault + 17539
    frame #74: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #75: 0x0000000107f9ac42 libpython3.10.dylib`method_vectorcall + 338
    frame #76: 0x00000001080769bc libpython3.10.dylib`call_function + 428
    frame #77: 0x0000000108072ec1 libpython3.10.dylib`_PyEval_EvalFrameDefault + 24817
    frame #78: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #79: 0x0000000107f9ac42 libpython3.10.dylib`method_vectorcall + 338
    frame #80: 0x0000000107f986ab libpython3.10.dylib`PyVectorcall_Call + 155
    frame #81: 0x0000000108073326 libpython3.10.dylib`_PyEval_EvalFrameDefault + 25942
    frame #82: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #83: 0x00000001080769bc libpython3.10.dylib`call_function + 428
    frame #84: 0x0000000108072f65 libpython3.10.dylib`_PyEval_EvalFrameDefault + 24981
    frame #85: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #86: 0x0000000107f9ac42 libpython3.10.dylib`method_vectorcall + 338
    frame #87: 0x00000001080769bc libpython3.10.dylib`call_function + 428
    frame #88: 0x0000000108072f65 libpython3.10.dylib`_PyEval_EvalFrameDefault + 24981
    frame #89: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #90: 0x0000000107f9ac42 libpython3.10.dylib`method_vectorcall + 338
    frame #91: 0x00000001080769bc libpython3.10.dylib`call_function + 428
    frame #92: 0x0000000108072f65 libpython3.10.dylib`_PyEval_EvalFrameDefault + 24981
    frame #93: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #94: 0x0000000107f986ab libpython3.10.dylib`PyVectorcall_Call + 155
    frame #95: 0x0000000108073326 libpython3.10.dylib`_PyEval_EvalFrameDefault + 25942
    frame #96: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #97: 0x0000000107f9ac42 libpython3.10.dylib`method_vectorcall + 338
    frame #98: 0x0000000107f986ab libpython3.10.dylib`PyVectorcall_Call + 155
    frame #99: 0x0000000108073326 libpython3.10.dylib`_PyEval_EvalFrameDefault + 25942
    frame #100: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #101: 0x0000000107f9ac42 libpython3.10.dylib`method_vectorcall + 338
    frame #102: 0x0000000107f986ab libpython3.10.dylib`PyVectorcall_Call + 155
    frame #103: 0x0000000108073326 libpython3.10.dylib`_PyEval_EvalFrameDefault + 25942
    frame #104: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #105: 0x00000001080769bc libpython3.10.dylib`call_function + 428
    frame #106: 0x0000000108072e95 libpython3.10.dylib`_PyEval_EvalFrameDefault + 24773
    frame #107: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #108: 0x00000001080769bc libpython3.10.dylib`call_function + 428
    frame #109: 0x0000000108072e95 libpython3.10.dylib`_PyEval_EvalFrameDefault + 24773
    frame #110: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #111: 0x00000001080769bc libpython3.10.dylib`call_function + 428
    frame #112: 0x000000010806d3e2 libpython3.10.dylib`_PyEval_EvalFrameDefault + 1554
    frame #113: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #114: 0x00000001080769bc libpython3.10.dylib`call_function + 428
    frame #115: 0x000000010806d3e2 libpython3.10.dylib`_PyEval_EvalFrameDefault + 1554
    frame #116: 0x000000010806cca2 libpython3.10.dylib`_PyEval_Vector + 146
    frame #117: 0x000000010806cbf8 libpython3.10.dylib`PyEval_EvalCode + 120
    frame #118: 0x00000001080bb305 libpython3.10.dylib`run_mod + 149
    frame #119: 0x00000001080b946a libpython3.10.dylib`_PyRun_SimpleFileObject + 954
    frame #120: 0x00000001080b8ecb libpython3.10.dylib`_PyRun_AnyFileObject + 123
    frame #121: 0x00000001080d7bcf libpython3.10.dylib`Py_RunMain + 2447
    frame #122: 0x00000001080d7e7a libpython3.10.dylib`pymain_main + 314
    frame #123: 0x00000001080d7ecb libpython3.10.dylib`Py_BytesMain + 43
    frame #124: 0x00007ff812c8c41f dyld`start + 1903

My situation has the following similarities and differences to OP's case.

I also attempted to get it to crash under GDB, but I could not reproduce the crash in that case.

I can't provide the core dump itself - it contains proprietary data that I don't know how to remove. However, I can provide information from the core dump, if that's helpful.