Skip to content

Validate untrusted hyperloglog estimator states - #2440

Open
reshke wants to merge 1 commit into
apache:mainfrom
reshke:fix-gp-hyperloglog-crash
Open

reshke wants to merge 1 commit into
apache:mainfrom
reshke:fix-gp-hyperloglog-crash

Conversation

@reshke

@reshke reshke commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

On main, a malformed b=127 state reaches gp_hll_unpack() while planning this estimate and fails with an impossible allocation request:

SELECT gp_hyperloglog_get_estimate(encode(decode('7f040200ffffffff' ||
repeat('00',72), 'hex'), 'base64')::gp_hyperloglog_estimator);
ERROR: invalid memory alloc request size 18446744071562068048 (mcxt.c:1511)
Stack: gp_hll_unpack -> gp_hyperloglog_estimate ->
gp_hyperloglog_get_estimate -> evaluate_expr -> planner.

Reproduced on a cassert/debug build; the HLL source and header match main 3af3d64. The backend stayed alive; this is a query ERROR, not a process termination.

@Alena0704
Alena0704 self-requested a review November 27, 2026 09:08
On main, a malformed b=127 state reaches gp_hll_unpack() while planning
this estimate and fails with an impossible allocation request:

SELECT gp_hyperloglog_get_estimate(encode(decode('7f040200ffffffff' ||
       repeat('00',72), 'hex'), 'base64')::gp_hyperloglog_estimator);
ERROR: invalid memory alloc request size 18446744071562068048 (mcxt.c:1511)
Stack: gp_hll_unpack -> gp_hyperloglog_estimate ->
       gp_hyperloglog_get_estimate -> evaluate_expr -> planner.

Reproduced on a cassert/debug build; the HLL source and header match main
3af3d64. The backend stayed alive; this is
a query ERROR, not a process termination.

Refresh gp_hyperloglog.out by removing blank separator lines after the
expected errors, which pg_regress does not emit.
@reshke
reshke force-pushed the fix-gp-hyperloglog-crash branch from 6b85d08 to 15df1cf Compare November 29, 2026 19:56
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.

1 participant