Skip to content

Fix misaligned xl_xact_distrib read in ParseCommitRecord - #2203

Merged
yjhjstz merged 1 commit into
apache:mainfrom
reshke:fix-ubsan-xactdesc-distrib-alignment
Oct 31, 2026
Merged

yjhjstz merged 1 commit into
apache:mainfrom
reshke:fix-ubsan-xactdesc-distrib-alignment

Conversation

@reshke

@reshke reshke commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

UBSan reported a misaligned member access when decoding the distributed-transaction field of commit WAL records during crash-recovery redo. The WAL record payload has no alignment guarantee; the neighboring xl_origin branch already copies onto the stack for exactly this reason. Do the same for xl_xact_distrib.

Sanitizer report (UBSan, instrumented build, crash recovery):
xactdesc.c:155:34: runtime error: member access within misaligned
address 0x7b39d104de44 for type 'struct xl_xact_distrib', which
requires 8 byte alignment
#0 ParseCommitRecord xactdesc.c:155
#1 xact_redo xactdesc.c:...
#2 ApplyWalRecord xlogrecovery.c:2023
#3 PerformWalRecovery xlogrecovery.c:1845
Undefined behavior at recovery time; harmless on x86_64 but incorrect on strictly aligned targets.

Fixes #ISSUE_Number

What does this PR do?

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


@leborchuk leborchuk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@tuhaihe
tuhaihe requested a review from yjhjstz October 28, 2026 01:48

@Alena0704 Alena0704 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@yjhjstz yjhjstz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@yjhjstz
yjhjstz enabled auto-merge (rebase) October 29, 2026 20:56
@yjhjstz
yjhjstz force-pushed the fix-ubsan-xactdesc-distrib-alignment branch from 1b885f7 to 5724382 Compare October 29, 2026 20:56
@tuhaihe
tuhaihe force-pushed the fix-ubsan-xactdesc-distrib-alignment branch from 5724382 to 6325655 Compare October 30, 2026 11:48
UBSan reported a misaligned member access when decoding the
distributed-transaction field of commit WAL records during
crash-recovery redo. The WAL record payload has no alignment
guarantee; the neighboring xl_origin branch already copies onto the
stack for exactly this reason. Do the same for xl_xact_distrib.

Sanitizer report (UBSan, instrumented build, crash recovery):
  xactdesc.c:155:34: runtime error: member access within misaligned
  address 0x7b39d104de44 for type 'struct xl_xact_distrib', which
  requires 8 byte alignment
  #0 ParseCommitRecord xactdesc.c:155
  #1 xact_redo xactdesc.c:...
  #2 ApplyWalRecord xlogrecovery.c:2023
  #3 PerformWalRecovery xlogrecovery.c:1845
Undefined behavior at recovery time; harmless on x86_64 but
incorrect on strictly aligned targets.
@tuhaihe
tuhaihe force-pushed the fix-ubsan-xactdesc-distrib-alignment branch from 6325655 to 3e785b3 Compare October 31, 2026 01:31
@yjhjstz
yjhjstz merged commit 0d77503 into apache:main Oct 31, 2026
121 of 122 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants