Skip to content

Fix uninitialised LOCALLOCK read in lock unit test - #2196

Merged
tuhaihe merged 1 commit into
apache:mainfrom
tuhaihe:fix-lock-test-uninit-read
Nov 21, 2026
Merged

tuhaihe merged 1 commit into
apache:mainfrom
tuhaihe:fix-lock-test-uninit-read

Conversation

@tuhaihe

@tuhaihe tuhaihe commented Oct 27, 2026

Copy link
Copy Markdown
Member

test__RemoveLocalLock_Null inserts a LOCALLOCK with hash_search(), which sets only the key, then sets lockOwners to NULL and calls RemoveLocalLock(). That also reads numLockOwners, to walk lockOwners, and holdsStrongLockCount, and both are uninitialised. The test passes as long as the memory happens to be zero; with glibc's MALLOC_PERTURB_ set, as meson test sets it, numLockOwners is garbage and the loop dereferences the NULL array.

Clear the entry past its key, as LockAcquireExtended() does for a new one.

Assisted-by: Claude Code

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


@tuhaihe tuhaihe added this to the 3.0 milestone Oct 27, 2026
@tuhaihe

tuhaihe commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

We found this issue in #1940.

@tuhaihe tuhaihe mentioned this pull request Oct 27, 2026
1 of 13 tasks
@tuhaihe tuhaihe modified the milestones: 3.0, 3.x Meson Oct 27, 2026

@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

@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

@tuhaihe
tuhaihe requested a review from leborchuk November 10, 2026 04:13
@Alena0704
Alena0704 force-pushed the fix-lock-test-uninit-read branch from 91336d1 to c4c3004 Compare November 16, 2026 11:13
test__RemoveLocalLock_Null inserts a LOCALLOCK with hash_search(), which
sets only the key, then sets lockOwners to NULL and calls
RemoveLocalLock(). That also reads numLockOwners, to walk lockOwners,
and holdsStrongLockCount, and both are uninitialised. The test passes as
long as the memory happens to be zero; with glibc's MALLOC_PERTURB_ set,
as meson test sets it, numLockOwners is garbage and the loop
dereferences the NULL array.

Clear the entry past its key, as LockAcquireExtended() does for a new
one.

Assisted-by: Claude Code
@tuhaihe
tuhaihe force-pushed the fix-lock-test-uninit-read branch from c4c3004 to 4e896b8 Compare November 21, 2026 09:20
@tuhaihe
tuhaihe enabled auto-merge (rebase) November 21, 2026 10:14
@tuhaihe
tuhaihe merged commit a9c906e into apache:main Nov 21, 2026
134 of 135 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.

3 participants