modular / modular/modular

[BUG] [stdlib] Stop passing assert_aborts child state through environment variables

Open
#6,910 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement mojo Mojo Libraries
Dominant language
Mojo
Stars
29.8k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

Review Mojo's priorities
What is your request?

_assert_aborts currently coordinates parent/child state (which call site to run, where to redirect output, etc..) by setenv-ing on the current process and relying on Process.run to inherit it into the child.

  • Mutating our own env before spawning and unsetting after is a TOCTOU hazard! Anything else touching the environment concurrently can race with it.
  • The output path goes through an env var + a file on disk, when it could just be an fd passed directly to the child. Process.run could grow envp support so we don't have to mutate our own process environment at all. And fd-passing so we don't need a temp file path either and would also likely be more portable.
  • There's also a real correctness gap from relying on envvar presence. If the location var is ever pre-set to a string that happens to match a real call site, the top-level process mistakes itself for the child and abort the whole suite in place instead of a child.

Ideally we could add envp (and ideally fd-passing) support to Process.run, then switch assert_aborts to use that instead of mutating/reading its own environment.

What is your motivation for this change?

N/A

Any other details?

No response

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

Start by tracing stdlib's _assert_aborts and Process.run paths, focusing on how child state, environment variables, output redirection, and call-site selection are passed. Done means assert_aborts no longer mutates or relies on the parent environment, and Process.run provides the needed child-process configuration without the described temporary-file path.

Written by the indexing model from the issue text.

Assessment

Domain
operating-systems, testing
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.