Initialize all `BaseStatistics` members and zero `stats_union` by krlmlr · Pull Request #23202 · duckdb/duckdb · GitHub
Skip to content

Initialize all BaseStatistics members and zero stats_union - #23202

Merged
Mytherin merged 1 commit into
duckdb:v1.5-variegatafrom
krlmlr:b-0037-base-statistics-uninitialized
Jun 11, 2026
Merged

Mytherin merged 1 commit into
duckdb:v1.5-variegatafrom
krlmlr:b-0037-base-statistics-uninitialized

Conversation

@krlmlr

@krlmlr krlmlr commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

I've seen Valgrind complaining when the move constructor touches fields which are not initialized by default constructors. I can't tell whether this problem is "harmless by design" or whether we should really initialize and rely on the compiler optimizing it out where it matters.

Claude writes:

The default constructor and Construct() left has_null, has_no_null and stats_union (including its padding bytes) indeterminate; copies made during statistics propagation in the optimizer can read those bytes before CreateEmpty/CreateUnknown overwrite them, which valgrind flags in StringValueComparison. The new values match InitializeEmpty(), so behaviour is unchanged.

Claude writes:

The default constructor and `Construct()` left `has_null`, `has_no_null` and `stats_union` (including its padding bytes) indeterminate; copies made during statistics propagation in the optimizer can read those bytes before `CreateEmpty`/`CreateUnknown` overwrite them, which valgrind flags in `StringValueComparison`. The new values match `InitializeEmpty()`, so behaviour is unchanged.
@krlmlr
krlmlr marked this pull request as ready for review June 10, 2026 19:15
@Mytherin
Mytherin merged commit c18e711 into duckdb:v1.5-variegata Jun 11, 2026
112 checks passed
@Mytherin

Copy link
Copy Markdown
Member

krlmlr pushed a commit to krlmlr/duckdb that referenced this pull request Jun 21, 2026
Conflict-free merge of the clean commits between resolutions:
  - Replace ARTConflictType::TRANSACTION with fatal exception (duckdb#23193)
  - [Dev] Fix variant shredding analysis logic discrepancy with shredded writing (duckdb#23194)
  - Initialize all `BaseStatistics` members and zero `stats_union` (duckdb#23202)
  - Initialize `TransactionContext::invalidation_policy` and `auto_rollback` (duckdb#23203)
krlmlr pushed a commit to krlmlr/duckdb that referenced this pull request Jun 21, 2026
…b#23202)

I've seen Valgrind complaining when the move constructor touches fields
which are not initialized by default constructors. I can't tell whether
this problem is "harmless by design" or whether we should really
initialize and rely on the compiler optimizing it out where it matters.

Claude writes:

The default constructor and `Construct()` left `has_null`, `has_no_null`
and `stats_union` (including its padding bytes) indeterminate; copies
made during statistics propagation in the optimizer can read those bytes
before `CreateEmpty`/`CreateUnknown` overwrite them, which valgrind
flags in `StringValueComparison`. The new values match
`InitializeEmpty()`, so behaviour is unchanged.
krlmlr pushed a commit to krlmlr/duckdb that referenced this pull request Jun 21, 2026
Conflict-free merge of the clean commits between resolutions:
  - Replace ARTConflictType::TRANSACTION with fatal exception (duckdb#23193)
  - [Dev] Fix variant shredding analysis logic discrepancy with shredded writing (duckdb#23194)
  - Initialize all `BaseStatistics` members and zero `stats_union` (duckdb#23202)
  - Initialize `TransactionContext::invalidation_policy` and `auto_rollback` (duckdb#23203)
krlmlr pushed a commit to krlmlr/duckdb that referenced this pull request Jun 21, 2026
Brings these v1.5-variegata commits; they do not overlap with the main/v2.0
line, so they merge with no conflicts:

- Replace ARTConflictType::TRANSACTION with fatal exception (duckdb#23193)
- [Dev] Fix variant shredding analysis logic discrepancy with shredded writing (duckdb#23194)
- Initialize all `BaseStatistics` members and zero `stats_union` (duckdb#23202)
- Initialize `TransactionContext::invalidation_policy` and `auto_rollback` (duckdb#23203)
@krlmlr
krlmlr deleted the b-0037-base-statistics-uninitialized branch June 21, 2026 15:12
krlmlr pushed a commit to krlmlr/duckdb that referenced this pull request Jun 21, 2026
Brings these v1.5-variegata commits; they do not overlap with the main/v2.0
line, so they merge with no conflicts:

- Replace ARTConflictType::TRANSACTION with fatal exception (duckdb#23193)
- [Dev] Fix variant shredding analysis logic discrepancy with shredded writing (duckdb#23194)
- Initialize all `BaseStatistics` members and zero `stats_union` (duckdb#23202)
- Initialize `TransactionContext::invalidation_policy` and `auto_rollback` (duckdb#23203)
kaka11chen pushed a commit to kaka11chen/astrovela_vane that referenced this pull request Aug 14, 2026
…b/duckdb#23202)

I've seen Valgrind complaining when the move constructor touches fields
which are not initialized by default constructors. I can't tell whether
this problem is "harmless by design" or whether we should really
initialize and rely on the compiler optimizing it out where it matters.

Claude writes:

The default constructor and `Construct()` left `has_null`, `has_no_null`
and `stats_union` (including its padding bytes) indeterminate; copies
made during statistics propagation in the optimizer can read those bytes
before `CreateEmpty`/`CreateUnknown` overwrite them, which valgrind
flags in `StringValueComparison`. The new values match
`InitializeEmpty()`, so behaviour is unchanged.

Upstream-Commit: duckdb/duckdb@c18e711
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants