Skip to content

Stop mocks of noreturn functions from returning - #2192

Open
tuhaihe wants to merge 1 commit into
apache:mainfrom
tuhaihe:fix-mocker-noreturn
Open

tuhaihe wants to merge 1 commit into
apache:mainfrom
tuhaihe:fix-mocker-noreturn

Conversation

@tuhaihe

@tuhaihe tuhaihe commented Oct 26, 2026

Copy link
Copy Markdown
Member

The unit test mocks that mocker.py generates end every void function with a plain mock() call. For the functions declared pg_attribute_noreturn() that means the mock falls off its end, and GCC warns on every build of the unit tests:

  elog_mock.c: warning: 'noreturn' function does return

It does so for ReThrowError, pg_re_throw, ExceptionalCondition, MemoryContextError, add_size_error, mul_size_error and WalSndShutdown.

Have mocker.py collect the functions declared pg_attribute_noreturn() in the source file and in the headers it includes, following includes through the file's own directory and src/include, and end their mocks with abort(). The tests leave these mocks through a side effect that longjmps, so the abort() is never reached; a test that forgot to set one now stops there instead of running on past a call the compiler assumed never returns.

The generated mocks differ from before only by those seven abort() calls.

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


The unit test mocks that mocker.py generates end every void function
with a plain mock() call.  For the functions declared
pg_attribute_noreturn() that means the mock falls off its end, and GCC
warns on every build of the unit tests:

  elog_mock.c: warning: 'noreturn' function does return

It does so for ReThrowError, pg_re_throw, ExceptionalCondition,
MemoryContextError, add_size_error, mul_size_error and WalSndShutdown.

Have mocker.py collect the functions declared pg_attribute_noreturn()
in the source file and in the headers it includes, following includes
through the file's own directory and src/include, and end their mocks
with abort().  The tests leave these mocks through a side effect that
longjmps, so the abort() is never reached; a test that forgot to set
one now stops there instead of running on past a call the compiler
assumed never returns.

The generated mocks differ from before only by those seven abort()
calls.

Assisted-by: Claude Code
@tuhaihe tuhaihe mentioned this pull request Oct 26, 2026
1 of 13 tasks
@tuhaihe tuhaihe added this to the 3.0 milestone Oct 26, 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, I always generate mocks, really no need to fix it manually

@tuhaihe tuhaihe modified the milestones: 3.0, 3.x Meson Oct 27, 2026
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