Skip to content

Conversation

@eriksjolund
Copy link
Contributor

@eriksjolund eriksjolund commented Dec 5, 2025

Summary by Sourcery

Bug Fixes:

  • Fix potential misuse of error release by ensuring crun_error_release is only called when an error is present and within the appropriate conditional scope.

Signed-off-by: Erik Sjölund <[email protected]>
@sourcery-ai
Copy link

sourcery-ai bot commented Dec 5, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts error handling in setup_executable_path so that non-ENOENT errors are released only when a specific condition is met, preventing premature error release in the container setup path.

File-Level Changes

Change Details Files
Scope the error-release logic so it only runs when the ENOENT early-return path is considered, avoiding unconditional crun_error_release on other paths.
  • Moved the explanatory comment and crun_error_release(err) call inside the conditional block that checks for a NULL custom_handler and ENOENT errno
  • Ensured that errors are only released in the non-ENOENT case when the ENOENT early-return logic is applicable
src/libcrun/container.c

Possibly linked issues

  • #0: The PR’s corrected error release likely fixes the SIGSEGV regression introduced by commit 379524f in krun.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `src/libcrun/container.c:1238-1242` </location>
<code_context>
             return ret;
-        }

-      /* If it fails for any other reason, ignore the failure.  We'll try again the lookup
-         once the process switched to the use that runs in the container.  This might be necessary
-         when opening a file that is on a network file system like NFS, where CAP_DAC_OVERRIDE
-         is not honored.  */
-      crun_error_release (err);
+          /* If it fails for any other reason, ignore the failure.  We'll try again the lookup
+             once the process switched to the use that runs in the container.  This might be necessary
</code_context>

<issue_to_address>
**issue (bug_risk):** The error object is never released anymore and the comment no longer matches the behavior.

With `crun_error_release(err);` moved inside the `if` and after `return ret;`, it becomes unreachable for the ENOENT path and is never called for other errors (since there is no release after the `if`). This changes behavior from "ignore failure but clean up" to leaking `err`. Please move `crun_error_release(err);` back outside the `if` or place it before the `return` so all paths release the error while keeping the ignore-and-retry behavior.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +1238 to +1242
once the process switched to the use that runs in the container. This might be necessary
when opening a file that is on a network file system like NFS, where CAP_DAC_OVERRIDE
is not honored. */
crun_error_release (err);
}
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): The error object is never released anymore and the comment no longer matches the behavior.

With crun_error_release(err); moved inside the if and after return ret;, it becomes unreachable for the ENOENT path and is never called for other errors (since there is no release after the if). This changes behavior from "ignore failure but clean up" to leaking err. Please move crun_error_release(err); back outside the if or place it before the return so all paths release the error while keeping the ignore-and-retry behavior.

@packit-as-a-service
Copy link

TMT tests failed. @containers/packit-build please check.

Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

LGTM

@giuseppe giuseppe merged commit 506e3d0 into containers:main Dec 5, 2025
61 of 65 checks passed
@eriksjolund eriksjolund deleted the fix-error-release branch December 6, 2025 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants