Skip to content

Potential (but highly unlikely) stack overflow #8

@rockymeza

Description

@rockymeza

If you have a super deeply nested expression, the Evaluator#resolve method is susceptible to stack overflows.

We could rewrite using a stack and a while loop to avoid this problem. (This may make it easier to build a stack trace for error messages too)

here's a failing test:

# The Evaluator#resolve method is susceptible to stack overflows.
# The test below uncovers that.
#
# it 'can evaluate nested expressions of arbitrary depth' do
# expression = ['add', 0, 1]
# 3843.times do
# expression = ['add', expression, 1]
# end
# expect(evaluator.resolve(expression)).to eq(3844)
# end

Notes:

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions