Fix stoi crash in Arrow format string parsing for w: and +w: types#21692
Merged
Mytherin merged 2 commits intoMar 30, 2026
Conversation
format.find(':') scanned the entire format string, matching colons in
extension metadata (e.g. GEOMETRY('ogc:crs84') from GeoParquet CRS).
Use fixed offsets per the Arrow C Data Interface spec instead: colon is
always at position 1 for "w:NN" and position 2 for "+w:NN".
Fixes duckdb#21691
Ref: duckdb/duckdb-wasm#2199
Mytherin
reviewed
Mar 29, 2026
Collaborator
Mytherin
left a comment
There was a problem hiding this comment.
Thanks! LGTM - one comment
Verify format conforms to spec before parsing (w:NN and +w:NN), throwing InvalidInputException for malformed strings.
carlopi
added a commit
to carlopi/duckdb-wasm
that referenced
this pull request
Apr 7, 2026
carlopi
added a commit
to duckdb/duckdb-wasm
that referenced
this pull request
Apr 7, 2026
carlopi
added a commit
to carlopi/duckdb-wasm
that referenced
this pull request
Apr 7, 2026
carlopi
added a commit
to duckdb/duckdb-wasm
that referenced
this pull request
Apr 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
format.find(':')inarrow_duck_schema.cppscanned the entire Arrow format string, matching colons in extension metadata (e.g.GEOMETRY('ogc:crs84')from GeoParquet CRS). This causedstd::stoito crash withstoi: no conversion.w:NN(fixed-size binary) and position 2 for+w:NN(fixed-size list).GetTypeFromFormatdirectly withw:format strings.Fixes #21691
Ref: duckdb/duckdb-wasm#2199
Changes
src/function/table/arrow/arrow_duck_schema.cpp(2 lines):format.substr(format.find(':') + 1)->format.substr(2)format.substr(format.find(':') + 1)->format.substr(3)test/arrow/arrow_roundtrip.cpp: newTEST_CASE("Test Arrow fixed-size binary format parsing")exercisingw:1,w:16,w:128.Test plan
[arrow]tests pass (131,509 assertions, 0 failures)