pest-parser / pest-parser/pest

Timeout in recursion

Open
#402 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug runtime-performance
Dominant language
Rust
Stars
5.4k
Forks
307
Avg merge
8h 23m
Merged PRs (30d)
5

Description

Found while fuzzing Tera v1.

The following expression is very slow: https://github.com/Keats/tera/blob/v1/src/tera.rs#L1028
and adding a level of recursion (eg _(p=__(p=[_(p=__(p=[_(p=[_(p=[_1(p=[_(p=[_1) will timeout

As far as I can see, the issue is that the rule fn_call is in the basic_val (https://github.com/Keats/tera/blob/v1/src/parser/tera.pest#L82) which is part of the potential values for a function argument -> recursing.

The issue seem to be in the generated lexer since it timeouts in the pest generated code.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the timeout from Tera v1 at src/tera.rs#L1028 using the recursive expression in the issue. Read the fn_call rule in src/parser/tera.pest#L82 and inspect the generated lexer code to trace the recursion. Done means the expression no longer times out.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.