annoy icon indicating copy to clipboard operation
annoy copied to clipboard

Segfaults running tests on Python 3.14

Open ngoldbaum opened this issue 2 months ago • 1 comments

Maybe I'm doing something wrong?

goldbaum at Nathans-MBP in ~/Documents/annoy on main!
± lldb -- $(pyenv which python) $(pyenv which pytest) -v
(lldb) target create "/Users/goldbaum/.pyenv/versions/3.14.0/bin/python"
Current executable set to '/Users/goldbaum/.pyenv/versions/3.14.0/bin/python' (arm64).
(lldb) settings set -- target.run-args  "/Users/goldbaum/.pyenv/versions/3.14.0/bin/pytest" "-v"
(lldb) r
Process 38730 launched: '/Users/goldbaum/.pyenv/versions/3.14.0/bin/python' (arm64)
============================= test session starts ==============================
platform darwin -- Python 3.14.0, pytest-8.4.2, pluggy-1.6.0 -- /Users/goldbaum/.pyenv/versions/3.14.0/bin/python
cachedir: .pytest_cache
rootdir: /Users/goldbaum/Documents/annoy
collecting ... Process 38730 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xfffffffafe8a8000)
    frame #0: 0x0000000101a6aaf0 annoylib.cpython-314-darwin.so`Annoy::AnnoyIndex<int, float, Annoy::Angular, Annoy::Kiss64Random, Annoy::AnnoyIndexMultiThreadedBuildPolicy>::_get_all_nns(this=0x0000600003fec070, v=0x00006000016e8a10, n=100, search_k=<unavailable>, result=0x000000016fdfa4a8 size=0, distances=0x0000000000000000) const at annoylib.h:1470:15 [opt]
   1467	      S i = top.second;
   1468	      Node* nd = _get(i);
   1469	      q.pop();
-> 1470	      if (nd->n_descendants == 1 && i < _n_items) {
   1471	        nns.push_back(i);
   1472	      } else if (nd->n_descendants <= _K) {
   1473	        const S* dst = nd->children;
Target 0: (python) stopped.
warning: annoylib.cpython-314-darwin.so was compiled with optimization - stepping may behave oddly; variables may not be available.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xfffffffafe8a8000)
  * frame #0: 0x0000000101a6aaf0 annoylib.cpython-314-darwin.so`Annoy::AnnoyIndex<int, float, Annoy::Angular, Annoy::Kiss64Random, Annoy::AnnoyIndexMultiThreadedBuildPolicy>::_get_all_nns(this=0x0000600003fec070, v=0x00006000016e8a10, n=100, search_k=<unavailable>, result=0x000000016fdfa4a8 size=0, distances=0x0000000000000000) const at annoylib.h:1470:15 [opt]
    frame #1: 0x0000000101a6533c annoylib.cpython-314-darwin.so`py_an_get_nns_by_vector(self=0x000000010189b950, args=<unavailable>, kwargs=<unavailable>) at annoymodule.cc:374:14 [opt]
    frame #2: 0x000000010074f820 libpython3.14.dylib`method_vectorcall_VARARGS_KEYWORDS + 236
    frame #3: 0x00000001007424c8 libpython3.14.dylib`PyObject_Vectorcall + 88
    frame #4: 0x000000010088087c libpython3.14.dylib`_PyEval_EvalFrameDefault + 12920
    frame #5: 0x000000010087d0f0 libpython3.14.dylib`PyEval_EvalCode + 416
    frame #6: 0x000000010087998c libpython3.14.dylib`builtin_exec + 1416
    frame #7: 0x00000001007424c8 libpython3.14.dylib`PyObject_Vectorcall + 88
    frame #8: 0x000000010088087c libpython3.14.dylib`_PyEval_EvalFrameDefault + 12920
    frame #9: 0x000000010087d32c libpython3.14.dylib`_PyEval_Vector + 512
    frame #10: 0x0000000100742838 libpython3.14.dylib`PyObject_CallOneArg + 108
    frame #11: 0x00000001007a11ec libpython3.14.dylib`_PyObject_GenericGetAttrWithDict + 488
    frame #12: 0x00000001007a0870 libpython3.14.dylib`PyObject_GetAttr + 112
    frame #13: 0x00000001008884cc libpython3.14.dylib`_PyEval_EvalFrameDefault + 44744
    frame #14: 0x000000010087d32c libpython3.14.dylib`_PyEval_Vector + 512
    frame #15: 0x000000010074197c libpython3.14.dylib`_PyObject_VectorcallDictTstate + 144
    frame #16: 0x0000000100742ee0 libpython3.14.dylib`_PyObject_Call_Prepend + 152
    frame #17: 0x00000001007d62fc libpython3.14.dylib`slot_tp_call + 128
    frame #18: 0x0000000100741bb4 libpython3.14.dylib`_PyObject_MakeTpCall + 292
    frame #19: 0x0000000100884f14 libpython3.14.dylib`_PyEval_EvalFrameDefault + 30992
    frame #20: 0x000000010075edc4 libpython3.14.dylib`gen_send_ex2 + 600
    frame #21: 0x000000010075d6e4 libpython3.14.dylib`gen_iternext + 36
    frame #22: 0x000000010077394c libpython3.14.dylib`list_extend_iter_lock_held + 268
    frame #23: 0x00000001007702b4 libpython3.14.dylib`list_extend + 12
    frame #24: 0x00000001007424c8 libpython3.14.dylib`PyObject_Vectorcall + 88
    frame #25: 0x000000010088087c libpython3.14.dylib`_PyEval_EvalFrameDefault + 12920
    frame #26: 0x000000010087d32c libpython3.14.dylib`_PyEval_Vector + 512
    frame #27: 0x000000010074197c libpython3.14.dylib`_PyObject_VectorcallDictTstate + 144
    frame #28: 0x0000000100742ee0 libpython3.14.dylib`_PyObject_Call_Prepend + 152
    frame #29: 0x00000001007d62fc libpython3.14.dylib`slot_tp_call + 128
    frame #30: 0x0000000100741bb4 libpython3.14.dylib`_PyObject_MakeTpCall + 292
    frame #31: 0x000000010087e5d0 libpython3.14.dylib`_PyEval_EvalFrameDefault + 4044
    frame #32: 0x000000010087d32c libpython3.14.dylib`_PyEval_Vector + 512
    frame #33: 0x000000010074197c libpython3.14.dylib`_PyObject_VectorcallDictTstate + 144
    frame #34: 0x0000000100742ee0 libpython3.14.dylib`_PyObject_Call_Prepend + 152
    frame #35: 0x00000001007d62fc libpython3.14.dylib`slot_tp_call + 128
    frame #36: 0x0000000100741bb4 libpython3.14.dylib`_PyObject_MakeTpCall + 292
    frame #37: 0x000000010087e5d0 libpython3.14.dylib`_PyEval_EvalFrameDefault + 4044
    frame #38: 0x000000010087d0f0 libpython3.14.dylib`PyEval_EvalCode + 416
    frame #39: 0x00000001008fa1ac libpython3.14.dylib`run_mod + 952
    frame #40: 0x00000001008f71f0 libpython3.14.dylib`_PyRun_SimpleFileObject + 860
    frame #41: 0x00000001008f6bac libpython3.14.dylib`_PyRun_AnyFileObject + 160
    frame #42: 0x00000001009218a4 libpython3.14.dylib`pymain_run_file + 336
    frame #43: 0x0000000100921170 libpython3.14.dylib`Py_RunMain + 1572
    frame #44: 0x00000001009213e8 libpython3.14.dylib`pymain_main + 320
    frame #45: 0x0000000100921488 libpython3.14.dylib`Py_BytesMain + 40
    frame #46: 0x000000019c152b98 dyld`start + 6076

ngoldbaum avatar Oct 22 '25 20:10 ngoldbaum

FWIW, I'm seeing this same segfault in the same place on Python 3.13 in my own use case.

jdcc avatar Nov 20 '25 18:11 jdcc