[pull] master from ruby:master - #1450
Merged
Merged
Conversation
capa does not include the terminator, so when a buffer moves
between strings with different terminator lengths the capacity has to
be converted or we will try to free the buffer with the wrong size:
[BUG] buffer 0x00005030039ff768 freed with old_size=18, but was allocated with size=17
[BUG] buffer 0x00005631adc48f48 freed with old_size=8268, but was allocated with size=8269
Three related fixes:
* `rb_str_tmp_frozen_release`: convert tmp's capacity to orig's
terminator length when handing the buffer back. This is the inverse
of a calculation added to `rb_str_tmp_frozen_no_embed_acquire` in
91619f0.
* `heap_str_make_shared`: since bdf3032
the root created by `rb_str_tmp_frozen_acquire` does not copy the
encoding of the string it takes the buffer from, so the two can have
different terminator lengths and the root's capacity has to be
adjusted as well, otherwise the root frees fewer bytes than were
allocated once its only child stops sharing the buffer. termlen is
passed in because the caller assigns the encoding of the root after
this function returns.
* `rb_str_tmp_frozen_no_embed_acquire`: unset `STR_BORROWED` on the
root. `STR_SET_SHARED` sets `STR_BORROWED` on roots with
`klass == 0` to mark the ones that may have other children, but this
root only ever has orig as its child, so unset it like
`heap_str_make_shared` does. Any string that starts sharing the
root later will set the flag again. Without this
`rb_str_tmp_frozen_release` never gives the buffer back, so strings
written by `io_fwrite` stay shared and are copied on their next
modification.
The release and make_shared adjustments go together
as they were previously canceling each other out.
…n given Timeout.timeout in Ruby 2.3 takes at most two arguments, so EnvUtil.timeout always raised ArgumentError there. EnvUtil.terminate reaches it through Debugger#dump on Windows when gdb is installed, which broke test_terminate_reaps_exited_child on windows-latest 2.3. ruby/test-unit-ruby-core@42d15562b2 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It has been `#if 0` since 04e95f8 disabled it to avoid infinite recursion at loading transcoder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
include/ruby/win32.h already maps stat, lstat, access, truncate, utimensat, unlink, rename and getenv to the same rb_w32_* functions when compiling the core with RUBY_EXPORT. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Neither mswin nor mingw defines HAVE_GETGROUPS, so the remaining condition already covers Windows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The polling loop saved and restored the sets through fixed fd_set buffers, which hold only FD_SETSIZE (64) sockets. From the second poll on, sockets past that were no longer watched, so IO.select could miss them until the timeout. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
When FD_SETSIZE (64) or more sockets were ready, copy_fd stopped there and a ready pipe or other non-socket handle was left out of the result. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The polling loop restored every socket into the sets before checking the deadline, so a timed-out select returned them all as ready. When IO.select forced a zero timeout for buffered data, sockets with nothing to read were reported readable. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
RUBYLIB and -I are UTF-8 on Windows, but ruby_push_include walked them with CharNext in the ANSI code page. With a DBCS code page such as 932, the last byte of a UTF-8 character was taken as a lead byte and swallowed the following `;`, so `C:/あ;C:/b` became a single load path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… Windows
The dln_find.c object built on its own receives UTF-8 command names from process.c, but scanned them with CharNext in the ANSI code page. With a DBCS code page, a backslash after a multibyte character was missed, and `exec("あ\\foo", "x")` ran `あ\foo` found in PATH instead of the one under the current directory. The copy that win32.c includes keeps using its code page.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ruby_push_include was its last user. A path separator never appears inside a multibyte character, so walk RUBYLIB and -I by bytes everywhere. This also fixes the same skipped separator on Cygwin, where CharNext came from windows.h. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`rb_w32_write_console` returns the number of UTF-16 code units it wrote, so writing "あ" to a console returned 1 instead of 3 as it does for files and NUL. Use the result only to tell success, as the other callers do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On 64-bit Windows, WOW64 sets PROCESSOR_ARCHITEW6432 when a 32-bit process starts, like PROCESSOR_ARCHITECTURE under the x64 emulation on ARM64, so test_execopts_env and test_execopts_unsetenv_others fail on i386-mswin32. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On i386-mswin32 the ruby DLL has no arch prefix and is named vcruntime140-ruby410.dll, so the vcruntime140*.dll check rejected every x86 binary package. Match only the VC runtime DLL names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Breakages specific to i386-mswin32, such as the size_t atomic fetch_add and the prism bit.h build failure, were found only by auditing. Run check on x86 as well so that CI catches them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )