Skip to content

Close fds on error#5009

Merged
kolyshkin merged 4 commits intoopencontainers:mainfrom
kolyshkin:defer-close-init
Dec 3, 2025
Merged

Close fds on error#5009
kolyshkin merged 4 commits intoopencontainers:mainfrom
kolyshkin:defer-close-init

Conversation

@kolyshkin
Copy link
Copy Markdown
Contributor

@kolyshkin kolyshkin commented Nov 12, 2025

This addresses cases reported by @arinochk in #5008.

See individual commits for details.

@kolyshkin kolyshkin marked this pull request as ready for review November 12, 2025 22:47
Copy link
Copy Markdown
Member

@cyphar cyphar left a comment

Choose a reason for hiding this comment

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

It still feels a bit strange to defer closing stuff in startInitialization but it is what it is...

@cyphar cyphar linked an issue Nov 13, 2025 that may be closed by this pull request
@kolyshkin
Copy link
Copy Markdown
Contributor Author

It still feels a bit strange to defer closing stuff in startInitialization but it is what it is...

There are a few (well, 3, to be exact) comments in there saying normally this function does not return and the defers are never called unless there's an error. Yet it takes some time to realize how things work here.

@kolyshkin kolyshkin requested review from AkihiroSuda and rata December 2, 2025 23:15
This function calls Init what normally never returns, so the defer only
works if there is an error and we can safely use it to close those fds
we opened. This was done for most but not all fds.

Reported in issue 5008.

Reported-by: Arina Cherednik <arinacherednik034@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Reported in issue 5008.

Reported-by: Arina Cherednik <arinacherednik034@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Reported in issue 5008.

Reported-by: Arina Cherednik <arinacherednik034@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Reported in issue 5008.

Reported-by: Arina Cherednik <arinacherednik034@gmail.com>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin kolyshkin merged commit fd18588 into opencontainers:main Dec 3, 2025
37 checks passed
@cyphar cyphar mentioned this pull request Mar 12, 2026
@cyphar cyphar added the backport/1.4-done A PR in main branch which has been backported to release-1.4 label Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/1.4-done A PR in main branch which has been backported to release-1.4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SAST Potential resource leaks

3 participants