Skip to content
This repository was archived by the owner on Nov 12, 2025. It is now read-only.

Conversation

@GrapeBaBa
Copy link
Contributor

Fix #40

@GrapeBaBa GrapeBaBa requested review from a team, Copilot and wemeetagain November 1, 2025 04:13
@gemini-code-assist
Copy link

Summary of Changes

Hello @GrapeBaBa, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request implements a crucial fix to prevent resource exhaustion during test runs. By ensuring that test directories are properly closed, it eliminates the ProcessFdQuotaExceeded error, leading to more stable and reliable test execution. The change specifically targets a file descriptor leak in the test suite.

Highlights

  • Resource Management: Introduced a defer statement to ensure that test directories are explicitly closed after use, preventing potential file descriptor leaks.
  • Bug Fix: Addresses and resolves the error.ProcessFdQuotaExceeded issue that could occur during test execution due to unclosed file descriptors.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a resource leak in generated static tests by ensuring directory handles are properly closed after use.

  • Changes test_dir from const to var to allow deferred cleanup
  • Adds defer test_dir.close() to ensure proper resource cleanup

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes a file descriptor leak in the generated test code by ensuring test_dir is closed. This is a great fix to prevent error.ProcessFdQuotaExceeded.

However, I've noticed that the test generator script, test/spec/write_static_tests.zig, has similar file descriptor leaks. The directories opened for iteration on lines 57, 75, and 93 are not being closed. I recommend fixing these as well to fully resolve the issue. A robust pattern for this would be:

var it = (try std.fs.cwd().openDir(path, .{ .iterate = true })).iterate();
defer it.dir.close();
while (try it.next()) |entry| {
    // ...
}

I've also left a small suggestion on the changed code to improve its clarity.

\\ defer allocator.free(test_dir_name);
\\
\\ const test_dir = std.fs.cwd().openDir(test_dir_name, .{{}}) catch return error.SkipZigTest;
\\ var test_dir = std.fs.cwd().openDir(test_dir_name, .{{}}) catch return error.SkipZigTest;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The test_dir variable doesn't need to be mutable here. The std.fs.Dir.close method takes its self parameter by value, so it can be called on a const variable. Using const makes the intent clearer that the variable is not meant to be modified after initialization.

        \\    const test_dir = std.fs.cwd().openDir(test_dir_name, .{{}}) catch return error.SkipZigTest;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, close take mutable ptr

@wemeetagain wemeetagain merged commit ae3e0e5 into main Nov 4, 2025
9 checks passed
@wemeetagain wemeetagain deleted the fix_open_too_many_files branch November 4, 2025 12:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Too many open files when running static spec tests

3 participants