Skip to content

fix potential UB in ByteBool encoding#7518

Merged
a10y merged 5 commits intodevelopfrom
aduffy/bytebool-ub
Apr 17, 2026
Merged

fix potential UB in ByteBool encoding#7518
a10y merged 5 commits intodevelopfrom
aduffy/bytebool-ub

Conversation

@a10y
Copy link
Copy Markdown
Contributor

@a10y a10y commented Apr 17, 2026

Summary

Our existing ByteBool constructor accepts arbitrary bytes as input, and will attempt to transmute it to a &[bool]. If those bytes are not 0x00 or 0x01 that can trigger UB on release builds.

API Changes

We eliminate the ByteBool::as_slice() -> &[bool] method, replacing it with an accessor to the truthy byte values.

We don't really need to access this as a bool-slice anyway since we can do all operations on the bytes and wrap them back up as a ByteBool.

We also eliminate some old From constructors for ByteBool that I think we probably don't want lying around

Tests

No additional tests needed

Signed-off-by: Andrew Duffy <andrew@a10y.dev>
@a10y a10y requested review from AdamGS and connortsui20 April 17, 2026 16:19
@a10y a10y added the changelog/fix A bug fix label Apr 17, 2026
@a10y
Copy link
Copy Markdown
Contributor Author

a10y commented Apr 17, 2026

Hmm, actually this begs the question of, do we want to match Arrow 8-bit Bool representation, or do we want to force it to be a Rust bool?

https://arrow.apache.org/docs/format/CanonicalExtensions.html#bit-boolean

@a10y
Copy link
Copy Markdown
Contributor Author

a10y commented Apr 17, 2026

I think this should probably use 8-bit bool instead (i.e. truthy bytes = true, 0x00 = false).

Let me fix this up.

Signed-off-by: Andrew Duffy <andrew@a10y.dev>
@a10y a10y changed the title fix potential UB in ByteBool constructor fix potential UB in ByteBool encoding Apr 17, 2026
This reverts commit 655082c.

Signed-off-by: Andrew Duffy <andrew@a10y.dev>
@a10y a10y force-pushed the aduffy/bytebool-ub branch from 6367c77 to d9e61d0 Compare April 17, 2026 16:38
Signed-off-by: Andrew Duffy <andrew@a10y.dev>
@a10y a10y enabled auto-merge (squash) April 17, 2026 17:08
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 17, 2026

Merging this PR will not alter performance

✅ 1163 untouched benchmarks
⏩ 1457 skipped benchmarks1


Comparing aduffy/bytebool-ub (cd23309) with develop (102de51)

Open in CodSpeed

Footnotes

  1. 1457 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Signed-off-by: Andrew Duffy <andrew@a10y.dev>
@a10y a10y force-pushed the aduffy/bytebool-ub branch from f2c8146 to cd23309 Compare April 17, 2026 17:17
@a10y a10y merged commit 4d73f97 into develop Apr 17, 2026
58 checks passed
@a10y a10y deleted the aduffy/bytebool-ub branch April 17, 2026 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants