tree-sitter/py-tree-sitter

Fatal Python error: Segmentation fault

Open

#435 opened on Jan 6, 2026

 (4 comments) (0 reactions) (0 assignees)C (192 forks)github user discovery
help wanted

Repository metrics

Stars
 (1,486 stars)
PR merge metrics
 (Avg merge 4d 14h) (7 merged PRs in 30d)

Description

When I use py-tree-sitter to parse java codes, I met bellow problems:

Fatal Python error: Segmentation fault

Current thread 0x00007f37a02f9200 (most recent call first):
  Garbage-collecting
  File "/data/anaconda3/envs/code_parser/lib/python3.10/pathlib.py", line 625 in __str__
  File "/data/anaconda3/envs/code_parser/lib/python3.10/pathlib.py", line 632 in __fspath__
  File "/data/anaconda3/envs/code_parser/lib/python3.10/pathlib.py", line 1119 in open
  File "/data/anaconda3/envs/code_parser/lib/python3.10/pathlib.py", line 1134 in read_text
  File "/data3/certification/code_parser/code_parser/parser/java/java_code_parser.py", line 77 in _collect_declaration_infos
  File "/data3/certification/code_parser/code_parser/parser/java/java_code_parser.py", line 55 in parse
  File "/data3/certification/code_parser/code_parser/parser/java/project_code_parser.py", line 80 in parse
  File "/data3/certification/code_parser/code_parser/parser/code_parser.py", line 61 in parse
  File "/data3/certification/code_parser/examples/hdcertification.py", line 61 in main
  File "/data3/certification/code_parser/examples/hdcertification.py", line 68 in <module>

Extension modules: tree_sitter_java._binding, yaml._yaml (total: 2)

debug with gdb:

(gdb) bt full
#0  0x00000000004e226a in list_traverse ()
No symbol table info available.
#1  0x00000000004e215f in deduce_unreachable ()
No symbol table info available.
#2  0x00000000004e18d3 in gc_collect_main ()
No symbol table info available.
#3  0x000000000059265c in gc_collect_with_callback ()
No symbol table info available.
#4  0x00000000004d7daa in _PyObject_GC_New ()
No symbol table info available.
#5  0x00000000005a5adb in mbuf_alloc ()
No symbol table info available.
#6  0x00000000005a57ec in _PyManagedBuffer_FromObject ()
No symbol table info available.
#7  0x00000000005a5770 in PyMemoryView_FromObject.localalias ()
No symbol table info available.
#8  0x00007ffff12a0940 in node_get_text (self=0x7fffef0c89b0, _unused_payload=<optimized out>) at tree_sitter/binding/node.c:575
        end_byte = 0x7fffef4e8bb0
        start_byte = 0x7fffef4e8cd0
        slice = 0x7ffff1520140
---Type <return> to continue, or q <return> to quit---
        node_mv = <optimized out>
        node_slice = <optimized out>
        tree = 0x7fffeec08930
        result = 0x0
        start_offset = 1258
        end_offset = 1271
        bytes_result = <optimized out>
#9  0x00000000004fccd9 in _PyObject_GenericGetAttrWithDict.localalias ()
No symbol table info available.
#10 0x00000000004fb710 in PyObject_GetAttr.localalias ()
No symbol table info available.
#11 0x00000000004f2db7 in _PyEval_EvalFrameDefault ()
No symbol table info available.
#12 0x00000000004fe4cf in _PyFunction_Vectorcall ()
No symbol table info available.
#13 0x00000000004ee7cf in _PyEval_EvalFrameDefault ()
No symbol table info available.
#14 0x00000000004fe4cf in _PyFunction_Vectorcall ()
No symbol table info available.
#15 0x00000000004eebe1 in _PyEval_EvalFrameDefault ()

Is this a bug in this project? I'm currently able to parse normally by disabling gc.

Contributor guide