Skip to content

Use rb_len_t for String and Array lengths in the extension - #824

Merged
hsbt merged 2 commits into
masterfrom
claude/affectionate-kare-fba41b
Oct 11, 2026
Merged

hsbt merged 2 commits into
masterfrom
claude/affectionate-kare-fba41b

Conversation

@hsbt

@hsbt hsbt commented Oct 10, 2026

Copy link
Copy Markdown
Member

Ruby master added rb_len_t as the type of String and Array lengths (https://bugs.ruby-lang.org/issues/22400). Psych still keeps the length of the tag directives array in a long, and casts the lengths it gets from libyaml and libfyaml to long before creating Strings. Both would truncate on mswin once rb_len_t widens.

This switches them to rb_len_t. psych.h falls back to typedef long rb_len_t when HAVE_RB_LEN_T is not defined, so older Ruby builds the same code as before.

I ran rake compile and rake test with Ruby 3.3.12 and 4.1.0dev on x64-mswin64, both of which predate rb_len_t. The libfyaml backend does not build on Windows, so it is left to the libfyaml workflow.

Generated with Claude Code

hsbt and others added 2 commits October 10, 2026 03:55
It falls back to long on Ruby versions that do not define HAVE_RB_LEN_T, so the change also builds there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A cast to long would cut these lengths to 32 bits before they reach rb_str_new on mswin once rb_len_t widens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hsbt
hsbt merged commit e3d58a0 into master Oct 11, 2026
194 checks passed
@hsbt
hsbt deleted the claude/affectionate-kare-fba41b branch October 11, 2026 09:16
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