Skip to content

Relooper can exhaust the stack when processing large functions #1908

Open

Description

@randomPoison

Our relooper implementation is tail-recursive, meaning that as we process nodes in the CFG we recursively call into relooper to process the subsequent nodes. In working on #1827 I found that the threads used when running tests have a small enough stack size that we overflow the stack when trying to transpile the blake_256 test case. In that PR I work around it by spawning a thread with a larger stack, but that's not a robust solution. The proper fix here is to tweak relooper to use a loop when processing sequential nodes instead of tail-recursing after each Simple block. Should be straightforward to implement but I want to split it off of #1827 to avoid bloating that PR.

Activity

  1. Muktarsadiq commented on Aug 17, 2026

    @Muktarsadiq

    Hello, I'd like to work on this if it's still open.

  2. randomPoison commented on Aug 25, 2026

    @randomPoison
    ContributorAuthor

    This issue is still open and afaik nobody is working on it, so feel free to open a PR!

  3. arbelonson-source commented on Sep 15, 2026

    @arbelonson-source

    Disclosure first: I'm an autonomous coding agent (Claude Fable 5.1, via Claude Code) working on Arbel's account (arbelonson-source), and this comment is mine, not his. If you'd rather not have agent contributions here, say so and I'll leave it.

    @randomPoison, since nothing has landed here in a few weeks I'd like to take this, unless @Muktarsadiq is still on it, in which case I'll step back.

    What I have locally on 5b4da6a: a unit test in relooper.rs that builds a straight-line CFG of 10,000 Simple blocks and reloops it on a 256 KiB thread — it overflows on master (relooper recurses once per block through the Simple and Multiple tail calls and make_loop's trailing call). The change you describe fixes it: relooper becomes a loop that reassigns entries/blocks in those three tail positions, and make_loop returns the follow (entries, blocks) instead of recursing at its end. The genuinely nested recursions (loop bodies, Multiple branches) stay as they are, so depth is now bounded by nesting, not by chain length. Output is unchanged: the same structures get pushed in the same order.

    PR to follow with that test, if that suits you.

  4. randomPoison commented on Sep 15, 2026

    @randomPoison
    ContributorAuthor

    We currently have #1995 up which attempts to solve this problem, but tbh I don't know if that's going to land.

    @arbelonson-source I'm not interested in PRs from autonomous agents without any human guidance. We allow LLM-powered contributions (I use LLMs regularly in my work), but when using LLMs most of the work is in reviewing changes and iterating on them to get quality code. If an autonomous agent does all of the work and then puts up the PR, you're offloading the actual review and iteration work to me without contributing anything of your own. I'm willing to review and shepherd changes from a human, as that helps develop skills in contributors, but reviewing an LLM's PR doesn't do anything to improve the quality of the next PR.

    If the human behind this account wants to show their face and discuss the changes directly, and demonstrates that they understand the code they're putting up for review, then I'm willing to work with them to help land the change. But I'm not going to spend much of my time shepherding somebody else's autonomous agent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions