Skip to content

Error recovery causing stack overflow #3538

@kmod-midori

Description

@kmod-midori

Problem

Trying to parse this file: https://github.com/AcademySoftwareFoundation/Imath/blob/main/src/Imath/toFloat.h causes stack overflow with the Rust binding, and generates extremely large log on CLI.

The maintainer of the C grammar responded saying that this is expected due to error recovery (tree-sitter/tree-sitter-c#221), but how would I as a user guard against this? Stack overflow is not something that may be caught/recovered.

Steps to reproduce

git clone https://github.com/tree-sitter/tree-sitter-c
cd tree-sitter-c
tree-sitter parse ../Imath/src/Imath/toFloat.h > 1.log

killall -9 tree-sitter

ls -lah 1.log         
-rw-rw-r-- 1 user user 1.2G Aug 16 09:45 1.log

Expected behavior

CLI should exit without generating huge amounts of output, the Rust binding should not cause stack overflow.

Tree-sitter version (tree-sitter --version)

ree-sitter 0.22.6

Operating system/version

Ubuntu 22.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    error-recoveryRelated to error recovery mechanism

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions