Repository navigation
[#1496] Don't free the result of pgmoneta_get_user_name() in test_utils_missing_basic - #1497
Closed
lookslikeameya wants to merge 1 commit into
Closed
lookslikeameya wants to merge 1 commit into
lookslikeameya wants to merge 1 commit into
Conversation
Pranav-error
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @lookslikeameya. I checked this: pgmoneta_get_user_name() returns pw->pw_name directly, and the only other caller (admin.c) just passes it to warnx(). Freeing it the way the test did: on macOS 26.7.1 the process dies inside free() (exit status 133), and on glibc the free() goes through, but under ASan the next getpwuid() reports a heap-use-after-free, as you described. The header comment is a good addition. LGTM.
Contributor
Author
|
Thanks for testing :) |
Member
|
Please, rebase |
…test_utils_missing_basic
lookslikeameya
force-pushed
the
test-utils-user-name-free
branch
from
November 11, 2026 22:41
db4f82f to
bdfa1f5
Compare
Member
|
Rebased and merged. Thanks for your contribution ! |
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.
Fixes #1496.
pgmoneta_get_user_name()returnspw_namefromgetpwuid(), which the C library owns, buttest_utils_missing_basicfreed it. On macOS that aborts the whole test runner, so no summary is printed and the tests after it don't run. On glibc thefree()happens to succeed becausepw_nameis the start of glibc's internal buffer, but the nextgetpwuid()would then use freed memory.The test no longer frees it, and the header comment now says not to. The function itself is unchanged; its only other caller (
admin.c) already uses it correctly.Tested:
test/check.sh -m utils: 64/65 pass, includingtest_utils_missing_basic. Before, the run aborted with no summary. The remaining failure,test_utils_misc(pgmoneta_backtrace_string()), also fails onmainand is unrelated (will be working on that soon)test/check.shon macOS now runs all 297 tests instead of stopping inutils. The other failures also fail onmain, mostly the incremental backup crash fixed by [#1470] Fix incremental backups on macOS #1472.test/check.sh ci -m utils: 65/65 pass, no sanitizer reports.