Merged
Conversation
|
TMT tests failed. @containers/packit-build please check. |
eriksjolund
reviewed
Jan 24, 2026
src/libcrun/container.c
Outdated
Comment on lines
816
to
819
| { | ||
| libcrun_warning ("error executing hook `%s` (exit code: %d)", hooks[i]->path, ret); | ||
| crun_error_release (err); | ||
| } |
Contributor
Member
Author
There was a problem hiding this comment.
thanks!
The code was wrong, could you please look at the new version?
Contributor
There was a problem hiding this comment.
LGTM
(yes, I also prefer this version )
print the current error and release it. Closes: containers#1957 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
5634cad to
1644fb0
Compare
Contributor
|
After writing LGTM I started to wonder if it is more robust to use a bool diff --git a/src/libcrun/container.c b/src/libcrun/container.c
index 50b1074c..f26e7b95 100644
--- a/src/libcrun/container.c
+++ b/src/libcrun/container.c
@@ -801,6 +801,7 @@ do_hooks (runtime_spec_schema_config_schema *def, pid_t pid, const char *id, boo
ret = 0;
+ bool error_created = false;
for (i = 0; i < hooks_len; i++)
{
char **env = environ;
@@ -809,11 +810,14 @@ do_hooks (runtime_spec_schema_config_schema *def, pid_t pid, const char *id, boo
env = hooks[i]->env;
/* Release the error from the previous iteration, if any. */
- if (err && *err)
+ if (error_created)
crun_error_release (err);
ret = run_process_with_stdin_timeout_envp (hooks[i]->path, hooks[i]->args, cwd, hooks[i]->timeout, env,
stdin, stdin_len, out_fd, err_fd, err);
+ if (UNLIKELY (ret < 0))
+ error_created = true;
+
if (UNLIKELY (ret != 0))
{
if (keep_going)Maybe it could happen that If so then this would be undefined behaviour Lines 110 to 111 in ff8f451 I haven't checked if it could happen but I see that sometimes is used instead of |
Member
Author
|
yeah that is better. Would you like to open a PR? :-) |
Contributor
|
PR: #1965 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
print the current error and release it.
Closes: #1957