Repository navigation
Compile the CRC32C software fallback unconditionally (fixes NULL crc_impl on ARM) - #1349
Closed
Pranav-error wants to merge 1 commit into
Closed
Pranav-error wants to merge 1 commit into
Pranav-error wants to merge 1 commit into
Conversation
pgmoneta_crc_init() had its entire body wrapped in #ifdef HAVE_CRC32_SSE42, an x86-only macro. The software fallback implementation, pgmoneta_crc32c_software(), was also defined inside that same guard, so on any platform without HAVE_CRC32_SSE42 (ARM64 in particular) neither implementation is compiled, crc_init() is a no-op, and the crc_impl function pointer is left NULL. Every call to pgmoneta_create_crc32c_buffer() then branches through a NULL function pointer. The software implementation has no SSE4.2 dependency at all -- it's a plain lookup-table CRC -- so it belongs outside the SSE42-only guard. Only the actual SSE4.2 hardware path stays gated on HAVE_CRC32_SSE42 + runtime cpu_supports_sse42(). Found and verified live on macOS/arm64: pgmoneta-cli verify crashed every time with a SIGSEGV at address 0 inside get_controlfile_by_exact_path() -> pgmoneta_read_control_data(), which is the first thing that calls pgmoneta_create_crc32c_buffer() during backup verification. This was specifically what blocked PR pgmoneta#1316's test_cli_verify from ever completing on this platform; after this fix it passes. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This was referenced Oct 4, 2026
Collaborator
Author
|
The `build-linux (clang, Debug, 14)` check failure here is a pre-existing CI environment flake, not caused by this change -- it fails in the "Install Dependencies" step itself, before any build starts: ``` A package-mirror version mismatch in the base image. The same step fails the same way on `main` directly (e.g. run 36739031490, 2026-09-30), unrelated to any PR. I don't have rights to re-run the job on this repo -- happy to push an empty commit to retrigger if that's preferred, otherwise a maintainer re-run should clear it. |
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 #1346.
`pgmoneta_crc_init()`'s body, and the software CRC32C implementation it
falls back to, were both wrapped in `#ifdef HAVE_CRC32_SSE42` -- an
x86-only compiler-flag check. On any platform without it (ARM64, most
notably), `crc_init()` is a no-op, `crc_impl` stays `NULL`, and
`pgmoneta_create_crc32c_buffer()` calls through it unconditionally.
The software implementation is a plain lookup-table CRC with no SSE4.2
dependency, so it doesn't need to be gated at all. This moves it (and
the fallback assignment in `crc_init()`) outside the SSE42-only guard;
only the actual hardware-accelerated path stays conditional on
`HAVE_CRC32_SSE42` + a runtime `cpu_supports_sse42()` check.
Verified live on macOS/arm64: `pgmoneta-cli verify` crashed with
`SIGSEGV` at address 0 every time, inside
`get_controlfile_by_exact_path() -> pgmoneta_create_crc32c_buffer()`
(the first CRC check hit when reading a backup's `pg_control`). After
this fix, the same verify run completes successfully.
This was specifically what blocked PR #1316's `test_cli_verify` from
reaching the page-checksum logic it's meant to exercise -- with this
fix (and #1348) applied, that test now passes end-to-end for the first
time.