Repository navigation
[#1724] Fix AddressSanitizer SEGV in test_restore/test_utils, check.sh cleanup, and CI regressions - #1725
Conversation
65bdf9c to
2030291
Compare
Pranav-error
left a comment
There was a problem hiding this comment.
Thanks for picking this up. main has been red since dd85549 and this is the right crash: on the clang Debug jobs of main (run 45869251661), ASan reports a write SEGV in pgmoneta_mkdir (utils.c:1213) called from test_pgmoneta_copy_postgresql_restore_excludes_last_files (test_restore.c:218). pgmoneta_mkdir() puts a '\0' at each / and restores it, and the test passes string literals. The char x[] = "..." change in test_restore.c and test_utils.c fixes that on its own.
I'm not sure about the utils.c change, though:
- It is not needed for the crash once the tests pass arrays.
- It makes
pgmoneta_mkdir()return 1 for any path ofMAX_PATH(1024) characters or more, wheremkdir(2)on Linux accepts up toPATH_MAX(4096). Several callers build the path withpgmoneta_append()without a cap, e.g.to_tblspc(restore.c:3495),to_directory(restore.c:3571), and most callers do not check the return value, so a long path would now fail quietly later instead of being created.
Could you drop the utils.c part and keep the test fix? If the idea is to also protect callers that only have a const char* (like pgmoneta_wal_store_create(), which casts downstream_dir at wal_store.c:769), a heap copy with no length limit would keep the current behavior for long paths.
The art.c NULL check and the baseline update look right (static-analysis passes with 13), and $SUDO is set at the top of check.sh (lines 91-95), so the cleanup change is fine.
|
Hi @manishpatel00, any update on the review points above? main's clang Debug jobs are red on this |
2030291 to
c1c9e9f
Compare
|
Hi @Pranav-error, Thanks for the thoughtful review! You make a great point regarding I have:
Ready for re-testing. Thank you! |
… check.sh cleanup, and CI regressions Use mutable char arrays in test_restore.c and test_utils.c exclusion tests to avoid AddressSanitizer SEGV write violations caused by pgmoneta_mkdir() modifying directory separators in-place. Run tablespace directory cleanup in check.sh with $SUDO. In addition, check allocation in pgmoneta_art_iterator_create() to resolve the nullPointerOutOfMemory cppcheck finding (pgmoneta#1722), add a strict prototype for pgmoneta_validate_muse_configuration(void), and update the baseline for art.c and migration_pgbackrest.c. Fixes pgmoneta#1724 Fixes pgmoneta#1722 Signed-off-by: Manish Kumar <[email protected]>
c1c9e9f to
a4313da
Compare
|
Hi @Pranav-error, Update on the latest push:
All 13 CI checks have completed and passed (including static analysis, format check, storage engines, and all Clang/GCC debug & release matrix builds). Ready for review and merge whenever you are ready. Thank you! |
|
Merged. Thanks for your contribution ! |
Fixes #1724
Fixes #1722
Description
This PR resolves the current test suite and CI compilation failures on
main:test_restore.candtest_utils.cpassed string literals topgmoneta_mkdir(), which modifies path separators in-place. Because string literals reside in read-only memory, this triggered an ASan write violation. Defining the test path variables as stack-allocated mutable arrays (char src[] = ...) resolves the crash without alteringpgmoneta_mkdir()inutils.c./tmp/pgmoneta_tblspcsubdirectories with mode 700. Incheck.sh, cleanup now uses sudo to reliably remove these directories in non-root test environments.mallocinpgmoneta_art_iterator_create(), added strict prototypevoidtopgmoneta_validate_muse_configuration(void)to resolve GCC compilation failure onmain, and updated the cppcheck baseline forart.candmigration_pgbackrest.c.Rebased on the latest
mainand squashed into a single commit.