Skip to content

Fix PAX CException stack overflow by pass-by-reference and shrinking …#1770

Merged
gfphoenix78 merged 1 commit into
apache:mainfrom
gfphoenix78:fix-ex
Jun 1, 2026
Merged

Fix PAX CException stack overflow by pass-by-reference and shrinking …#1770
gfphoenix78 merged 1 commit into
apache:mainfrom
gfphoenix78:fix-ex

Conversation

@gfphoenix78
Copy link
Copy Markdown
Contributor

…buffer

CException is ~255KB due to stack_[DEFAULT_STACK_MAX_SIZE]. When Raise(CException ex, ...) passes by value, two copies (510KB) are placed on the stack, causing stack overflow in backtrace() -> dlopen().

Fix:

  • Change Raise/ReRaise to pass CException by reference instead of value
  • Reduce DEFAULT_STACK_MAX_SIZE to 1/4 (255KB -> 63KB)
  • Callers now construct a local CException and pass it by reference

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


Copy link
Copy Markdown
Contributor

@avamingli avamingli left a comment

Choose a reason for hiding this comment

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

LGTM.

@gfphoenix78 gfphoenix78 force-pushed the fix-ex branch 4 times, most recently from 312b52e to 1e838bd Compare May 31, 2026 06:14
Copy link
Copy Markdown
Contributor

@my-ship-it my-ship-it left a comment

Choose a reason for hiding this comment

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

LGTM, good catch!

Comment thread contrib/pax_storage/src/cpp/exceptions/CException.cc
…buffer

CException is ~255KB due to stack_[DEFAULT_STACK_MAX_SIZE]. When
Raise(CException ex, ...) passes by value, two copies (510KB) are
placed on the stack, causing stack overflow in backtrace() -> dlopen().

Fix:
- Change Raise/ReRaise to pass CException by reference instead of value
- Reduce DEFAULT_STACK_MAX_SIZE to 1/4 (255KB -> 63KB)
- Callers now construct a local CException and pass it by reference
@gfphoenix78 gfphoenix78 force-pushed the fix-ex branch 2 times, most recently from 53c5c8e to ea98724 Compare June 1, 2026 01:32
@gfphoenix78 gfphoenix78 merged commit c9dc773 into apache:main Jun 1, 2026
56 of 57 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