From 5299d8d132206707da9a656039ffcf7ecfb1cb10 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Fri, 25 Sep 2026 17:55:04 +0900 Subject: [PATCH 01/15] Dump Hash AR/ST status in ObjectSpace.dump --- ext/objspace/objspace_dump.c | 5 +++++ test/objspace/test_objspace.rb | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c index 7bd34864476c47..8cd5637edd7c3b 100644 --- a/ext/objspace/objspace_dump.c +++ b/ext/objspace/objspace_dump.c @@ -514,6 +514,11 @@ dump_object(VALUE obj, struct dump_config *dc) case T_HASH: dump_append(dc, ", \"size\":"); dump_append_sizet(dc, (size_t)RHASH_SIZE(obj)); + + if (RHASH_AR_TABLE_P(obj)) { + dump_append(dc, ", \"ar_table\":true"); + } + if (FL_TEST(obj, RHASH_PROC_DEFAULT)) { dump_append(dc, ", \"default\":"); dump_append_ref(dc, RHASH_IFNONE(obj)); diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb index 3f6f5e1b71400f..5ce4dac1a14d9f 100644 --- a/test/objspace/test_objspace.rb +++ b/test/objspace/test_objspace.rb @@ -515,6 +515,17 @@ def test_dump_array assert_not_include(info, '"embedded":true') end + def test_dump_hash + ar_hash = {} + info = ObjectSpace.dump(ar_hash) + assert_include(info, '"ar_table":true') + + st_hash = {} + 9.times { |i| st_hash[i] = i } + info = ObjectSpace.dump(st_hash) + assert_not_include(info, '"ar_table":true') + end + def test_dump_object klass = Class.new From b06042331faeea1d82de8cf9fa1813ee2a1a5970 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Sat, 26 Sep 2026 07:16:36 +0900 Subject: [PATCH 02/15] [ruby/resolv] Skip TestWin32Config without the win32/resolv extension JRuby on Windows loads its bundled `win32/resolv`, which has no `tcpip_params`, so two of these tests raised NoMethodError there. https://github.com/ruby/resolv/commit/971a36ee72 Co-Authored-By: Claude Opus 5.5 --- test/resolv/test_win32_config.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/resolv/test_win32_config.rb b/test/resolv/test_win32_config.rb index ced130c9ec8970..9e5c11521fa5be 100644 --- a/test/resolv/test_win32_config.rb +++ b/test/resolv/test_win32_config.rb @@ -3,7 +3,8 @@ require 'test/unit' require 'resolv' -if defined?(Win32::Resolv) +# JRuby loads its bundled win32/resolv, which lacks the registry access of the extension. +if defined?(Win32::Resolv) && Win32::Resolv.respond_to?(:tcpip_params, true) class TestWin32Config < Test::Unit::TestCase def test_get_item_property_string # Test reading a string registry value From 7223715408427f0d77582f3b07395e7560e33d69 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 25 Sep 2026 16:45:26 +0900 Subject: [PATCH 03/15] win32: Remove the PROCESSOR_FLAG default of ARCH_FLAG PROCESSOR_FLAG lost its only definition in cdb9893c55, so ARCH_FLAG has been empty unless given explicitly. Co-Authored-By: Claude Opus 5.5 --- win32/Makefile.sub | 3 --- win32/setup.mak | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/win32/Makefile.sub b/win32/Makefile.sub index b6881b197da066..52b16588f8551a 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -295,9 +295,6 @@ WERRORFLAG = -WX !if !defined(CFLAGS_NO_ARCH) CFLAGS_NO_ARCH = $(RUNTIMEFLAG) $(DEBUGFLAGS) $(WARNFLAGS) $(OPTFLAGS) $(COMPILERFLAG) !endif -!if !defined(ARCH_FLAG) -ARCH_FLAG = $(PROCESSOR_FLAG) -!endif !if !defined(CFLAGS) CFLAGS = $(CFLAGS_NO_ARCH) $(ARCH_FLAG) !endif diff --git a/win32/setup.mak b/win32/setup.mak index 5154aae35daadd..ee0d8f87d85467 100644 --- a/win32/setup.mak +++ b/win32/setup.mak @@ -293,7 +293,7 @@ MACHINE = $(@:-=) # RUBY_INSTALL_NAME = ruby # RUBY_SO_NAME = $$(RT)-$$(RUBY_INSTALL_NAME)$$(MAJOR)$$(MINOR) -# CFLAGS = $$(RUNTIMEFLAG) $$(DEBUGFLAGS) $$(WARNFLAGS) $$(OPTFLAGS) $$(PROCESSOR_FLAG) $$(COMPILERFLAG) +# CFLAGS = $$(RUNTIMEFLAG) $$(DEBUGFLAGS) $$(WARNFLAGS) $$(OPTFLAGS) $$(COMPILERFLAG) # CPPFLAGS = # STACK = 0x2000000 # LDFLAGS = $$(CFLAGS) -Fm From b0e813f4ccf43f96addf95eb00b5655e6b5ccf3b Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 25 Sep 2026 16:47:26 +0900 Subject: [PATCH 04/15] win32: Detect only vcruntime in rtname.cmd MSVC 1915 or later is required and Makefile.sub rejects RT_VER below 140, so the values made for msvcrt and msvcrNN only led to that error. Co-Authored-By: Claude Opus 5.5 --- win32/rtname.cmd | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/win32/rtname.cmd b/win32/rtname.cmd index b85c6a0c7c0d40..703331a82fdc54 100755 --- a/win32/rtname.cmd +++ b/win32/rtname.cmd @@ -5,7 +5,7 @@ set rtver= set osver= for /f "usebackq" %%I in (` dumpbin -dependents %1 ^| - findstr -r -i -c:"\&2 + (echo %0: %1 is not linked to vcruntime) 1>&2 exit 1 ) for %%I in ( From be0b81e7e72a5f2fc6c82deab1ad5cf553e10f81 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 25 Sep 2026 16:47:49 +0900 Subject: [PATCH 05/15] mswin: Stop building missing/langinfo.c Only the Cygwin branch in localeinit.c calls nl_langinfo_codeset, so on mswin the object just added an unused export to the DLL. Co-Authored-By: Claude Opus 5.5 --- win32/Makefile.sub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win32/Makefile.sub b/win32/Makefile.sub index 52b16588f8551a..fd8140116514af 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -323,7 +323,7 @@ LIBS = $(LIBS) gmp.lib LIBS = $(LIBS) imagehlp.lib shlwapi.lib bcrypt.lib $(EXTLIBS) !endif !if !defined(MISSING) -MISSING = crypt.obj ffs.obj langinfo.obj lgamma_r.obj strlcat.obj strlcpy.obj win32/win32.obj win32/file.obj setproctitle.obj +MISSING = crypt.obj ffs.obj lgamma_r.obj strlcat.obj strlcpy.obj win32/win32.obj win32/file.obj setproctitle.obj MISSING = $(MISSING) explicit_bzero.obj memrchr.obj !endif DLNOBJS = dln.obj From 9f1ea3dc53aaf7fcfc0b0edc4d71b93b5b1aba78 Mon Sep 17 00:00:00 2001 From: Burdette Lamar Date: Fri, 25 Sep 2026 22:05:25 -0500 Subject: [PATCH 06/15] [DOC] Harmonize truncate methods --- file.c | 65 +++++++++++++++++++++++++++++++-------------- pathname_builtin.rb | 15 +++++------ 2 files changed, 52 insertions(+), 28 deletions(-) diff --git a/file.c b/file.c index f144d82bf776d7..091f8bca6d2974 100644 --- a/file.c +++ b/file.c @@ -6226,23 +6226,28 @@ nogvl_truncate(void *ptr) } /* + * :markup: markdown + * * call-seq: - * File.truncate(filepath, size) -> 0 + * File.truncate(filepath, size) -> 0 * - * Adjusts the size of file +filepath+ to the given size; returns 0: + * Adjusts the size of file `filepath` to the given `size`: * - * file = File.new('t.tmp', 'w+') - * file.write('0123456789') - * file.truncate(5) - * file.rewind - * file.read # => "01234" + * ```ruby + * filepath = '/tmp/t.tmp' + * File.write(filepath, '0123456789') + * File.read(filepath) # => "0123456789" + * File.truncate(filepath, 5) + * File.read(filepath) # => "01234" + * ``` * - * Pads on the right with null characters if necessary: + * Pads with null characters if necessary: * - * file.truncate(10) - * file.rewind - * file.read # => "01234\u0000\u0000\u0000\u0000\u0000" - * file.close + * ```ruby + * File.truncate(filepath, 10) + * File.read(filepath) # => "01234\u0000\u0000\u0000\u0000\u0000" + * File.delete(filepath) # Clean up. + * ``` * */ @@ -6281,17 +6286,37 @@ nogvl_ftruncate(void *ptr) } /* + * :markup: markdown + * * call-seq: - * file.truncate(integer) -> 0 + * truncate(size) -> 0 * - * Truncates file to at most integer bytes. The file - * must be opened for writing. Not available on all platforms. + * Adjusts the size of `self` to the given `size`, + * regardless of the current [position](rdoc-ref:IO@Position); + * does not adjust the position: + * + * ```ruby + * filepath = '/tmp/t.tmp' + * file = File.new(filepath, 'w+') + * file.write('0123456789') + * file.truncate(5) + * file.pos # => 10 + * file.rewind + * file.read # => "01234" + * ``` + * + * Pads with null characters if necessary: + * + * ```ruby + * file.truncate(10) + * file.pos # => 5 + * file.rewind + * file.read # => "01234\u0000\u0000\u0000\u0000\u0000" + * # Clean up. + * file.close + * File.delete(filepath) + * ``` * - * f = File.new("out", "w") - * f.syswrite("1234567890") #=> 10 - * f.truncate(5) #=> 0 - * f.close() #=> nil - * File.size("out") #=> 5 */ static VALUE diff --git a/pathname_builtin.rb b/pathname_builtin.rb index 4c330bd3cf228c..b373b9617fe548 100644 --- a/pathname_builtin.rb +++ b/pathname_builtin.rb @@ -1950,23 +1950,22 @@ def make_symlink(old) File.symlink(old, @path) end # call-seq: # truncate(size) -> 0 # - # Adjusts the size of file at the path in `self` to the given `size`; - # returns `0`: + # Adjusts the size of file at the path in `self` to the given `size`: # # ```ruby + # pn = Pathname('/tmp/t.tmp') # pn.write('0123456789') - # pn.size # => 10 + # pn.read # => "0123456789" # pn.truncate(5) - # pn.size # => 5 - # pn.read # => "01234" + # pn.read # => "01234" # ``` # - # Pads on the right with null characters if necessary: + # Pads with null characters if necessary: # # ```ruby # pn.truncate(10) - # pn.size # => 10 - # pn.read # => "01234\u0000\u0000\u0000\u0000\u0000" + # pn.read # => "01234\u0000\u0000\u0000\u0000\u0000" + # pn.delete # Clean up. # ``` # def truncate(length) File.truncate(@path, length) end From c45c9c26747789006e64c6a71572bffb2871bff7 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 25 Sep 2026 16:38:05 +0900 Subject: [PATCH 07/15] Reject MSVC older than 1915 in the public headers Building ruby needs `_MSC_VER` 1915 or later, but the generated config.h accepts 1910 and later for such a build, so an extension could still be compiled by 1910 through 1914. Co-Authored-By: Claude Opus 5.5 --- include/ruby/internal/compiler_is/msvc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/ruby/internal/compiler_is/msvc.h b/include/ruby/internal/compiler_is/msvc.h index 824f0ecc21e83a..c96a5c0c0f25ef 100644 --- a/include/ruby/internal/compiler_is/msvc.h +++ b/include/ruby/internal/compiler_is/msvc.h @@ -31,7 +31,7 @@ #elif RBIMPL_COMPILER_IS(Intel) # define RBIMPL_COMPILER_IS_MSVC 0 -#elif _MSC_VER >= 1400 +#elif _MSC_VER >= 1915 # define RBIMPL_COMPILER_IS_MSVC 1 # /* _MSC_FULL_VER = XXYYZZZZZ */ # define RBIMPL_COMPILER_VERSION_MAJOR (_MSC_FULL_VER / 10000000) From 62e374e9ef0d9edceddad73b181a3ce887a2ca28 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 25 Sep 2026 16:39:23 +0900 Subject: [PATCH 08/15] Fold MSVC version checks in the attribute detection headers Every `RBIMPL_COMPILER_SINCE(MSVC, ...)` condition here holds for `_MSC_VER` 1915, the oldest version the headers accept. Co-Authored-By: Claude Opus 5.5 --- include/ruby/internal/attr/constexpr.h | 6 ++--- include/ruby/internal/has/cpp_attribute.h | 12 +++++----- .../ruby/internal/has/declspec_attribute.h | 23 +++++++++---------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/include/ruby/internal/attr/constexpr.h b/include/ruby/internal/attr/constexpr.h index abc4f238b51079..d5aba4fd1385cc 100644 --- a/include/ruby/internal/attr/constexpr.h +++ b/include/ruby/internal/attr/constexpr.h @@ -34,9 +34,9 @@ # define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 (__cpp_constexpr >= 200704L) # define RBIMPL_HAS_ATTR_CONSTEXPR_CXX14 (__cpp_constexpr >= 201304L) -#elif RBIMPL_COMPILER_SINCE(MSVC, 19, 0, 0) -# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 RBIMPL_COMPILER_SINCE(MSVC, 19, 00, 00) -# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX14 RBIMPL_COMPILER_SINCE(MSVC, 19, 11, 00) +#elif RBIMPL_COMPILER_IS(MSVC) +# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 1 +# define RBIMPL_HAS_ATTR_CONSTEXPR_CXX14 1 #elif RBIMPL_COMPILER_SINCE(SunPro, 5, 13, 0) # define RBIMPL_HAS_ATTR_CONSTEXPR_CXX11 (__cplusplus >= 201103L) diff --git a/include/ruby/internal/has/cpp_attribute.h b/include/ruby/internal/has/cpp_attribute.h index 6a393b1a24cf9b..211bc21e600eae 100644 --- a/include/ruby/internal/has/cpp_attribute.h +++ b/include/ruby/internal/has/cpp_attribute.h @@ -42,12 +42,12 @@ # * 2019. However, they do have attributes since 2015 or so. */ # /* https://docs.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance */ # define RBIMPL_HAS_CPP_ATTRIBUTE0(_) (RBIMPL_HAS_CPP_ATTRIBUTE_ ## _) -# define RBIMPL_HAS_CPP_ATTRIBUTE_noreturn 200809 * RBIMPL_COMPILER_SINCE(MSVC, 19, 00, 0) -# define RBIMPL_HAS_CPP_ATTRIBUTE_carries_dependency 200809 * RBIMPL_COMPILER_SINCE(MSVC, 19, 00, 0) -# define RBIMPL_HAS_CPP_ATTRIBUTE_deprecated 201309 * RBIMPL_COMPILER_SINCE(MSVC, 19, 10, 0) -# define RBIMPL_HAS_CPP_ATTRIBUTE_fallthrough 201603 * RBIMPL_COMPILER_SINCE(MSVC, 19, 10, 0) -# define RBIMPL_HAS_CPP_ATTRIBUTE_maybe_unused 201603 * RBIMPL_COMPILER_SINCE(MSVC, 19, 11, 0) -# define RBIMPL_HAS_CPP_ATTRIBUTE_nodiscard 201603 * RBIMPL_COMPILER_SINCE(MSVC, 19, 11, 0) +# define RBIMPL_HAS_CPP_ATTRIBUTE_noreturn 200809 +# define RBIMPL_HAS_CPP_ATTRIBUTE_carries_dependency 200809 +# define RBIMPL_HAS_CPP_ATTRIBUTE_deprecated 201309 +# define RBIMPL_HAS_CPP_ATTRIBUTE_fallthrough 201603 +# define RBIMPL_HAS_CPP_ATTRIBUTE_maybe_unused 201603 +# define RBIMPL_HAS_CPP_ATTRIBUTE_nodiscard 201603 #elif RBIMPL_COMPILER_BEFORE(Clang, 3, 6, 0) # /* Clang 3.6.0 introduced __has_cpp_attribute. Prior to that following diff --git a/include/ruby/internal/has/declspec_attribute.h b/include/ruby/internal/has/declspec_attribute.h index 1c526daf78edb5..f8f500875001d4 100644 --- a/include/ruby/internal/has/declspec_attribute.h +++ b/include/ruby/internal/has/declspec_attribute.h @@ -20,24 +20,23 @@ * extension libraries. They could be written in C++98. * @brief Defines #RBIMPL_HAS_DECLSPEC_ATTRIBUTE. */ -#include "ruby/internal/compiler_since.h" +#include "ruby/internal/compiler_is.h" /** Wraps (or simulates) `__has_declspec_attribute`. */ #if defined(__has_declspec_attribute) # define RBIMPL_HAS_DECLSPEC_ATTRIBUTE(_) __has_declspec_attribute(_) #else # define RBIMPL_HAS_DECLSPEC_ATTRIBUTE(_) (RBIMPL_HAS_DECLSPEC_ATTRIBUTE_ ## _) -# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_align RBIMPL_COMPILER_SINCE(MSVC, 8, 0, 0) -# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_deprecated RBIMPL_COMPILER_SINCE(MSVC,13, 0, 0) -# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_dllexport RBIMPL_COMPILER_SINCE(MSVC, 8, 0, 0) -# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_dllimport RBIMPL_COMPILER_SINCE(MSVC, 8, 0, 0) -# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_empty_bases RBIMPL_COMPILER_SINCE(MSVC,19, 0, 23918) -# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_noalias RBIMPL_COMPILER_SINCE(MSVC, 8, 0, 0) -# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_noinline RBIMPL_COMPILER_SINCE(MSVC,13, 0, 0) -# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_noreturn RBIMPL_COMPILER_SINCE(MSVC,11, 0, 0) -# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_nothrow RBIMPL_COMPILER_SINCE(MSVC, 8, 0, 0) -# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_restrict RBIMPL_COMPILER_SINCE(MSVC,14, 0, 0) -# /* Note that "8, 0, 0" might be inaccurate. */ +# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_align RBIMPL_COMPILER_IS(MSVC) +# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_deprecated RBIMPL_COMPILER_IS(MSVC) +# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_dllexport RBIMPL_COMPILER_IS(MSVC) +# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_dllimport RBIMPL_COMPILER_IS(MSVC) +# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_empty_bases RBIMPL_COMPILER_IS(MSVC) +# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_noalias RBIMPL_COMPILER_IS(MSVC) +# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_noinline RBIMPL_COMPILER_IS(MSVC) +# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_noreturn RBIMPL_COMPILER_IS(MSVC) +# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_nothrow RBIMPL_COMPILER_IS(MSVC) +# define RBIMPL_HAS_DECLSPEC_ATTRIBUTE_restrict RBIMPL_COMPILER_IS(MSVC) # if ! defined(__cplusplus) # /* Clang has this in both C/C++, but MSVC has this in C++ only.*/ # undef RBIMPL_HAS_DECLSPEC_ATTRIBUTE_nothrow From 0fb144a7d9e4188094bddb4e181d59e453353288 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 25 Sep 2026 16:39:46 +0900 Subject: [PATCH 09/15] Remove unused MSC_VERSION_SINCE and MSC_VERSION_BEFORE The last use went away in cdb9893c55. Co-Authored-By: Claude Opus 5.5 --- internal/bits.h | 2 +- internal/compilers.h | 3 --- parser_bits.h | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/internal/bits.h b/internal/bits.h index 698ab3e2194159..64e6ac6896b363 100644 --- a/internal/bits.h +++ b/internal/bits.h @@ -28,7 +28,7 @@ #include "ruby/internal/config.h" #include /* for CHAR_BITS */ #include /* for uintptr_t */ -#include "internal/compilers.h" /* for MSC_VERSION_SINCE */ +#include "internal/compilers.h" /* for __has_builtin */ #ifdef _MSC_VER # include /* for _byteswap_uint64 */ diff --git a/internal/compilers.h b/internal/compilers.h index a19cade70513f9..c99b9afbfe78d9 100644 --- a/internal/compilers.h +++ b/internal/compilers.h @@ -18,9 +18,6 @@ #include "ruby/internal/has/warning.h" #include "ruby/backward/2/gcc_version_since.h" -#define MSC_VERSION_SINCE(_) RBIMPL_COMPILER_SINCE(MSVC, (_) / 100, (_) % 100, 0) -#define MSC_VERSION_BEFORE(_) RBIMPL_COMPILER_BEFORE(MSVC, (_) / 100, (_) % 100, 0) - #ifndef __has_attribute # define __has_attribute(...) RBIMPL_HAS_ATTRIBUTE(__VA_ARGS__) #endif diff --git a/parser_bits.h b/parser_bits.h index f894dde33e5e9e..058f0beadad90e 100644 --- a/parser_bits.h +++ b/parser_bits.h @@ -28,7 +28,7 @@ #include "ruby/internal/config.h" #include /* for CHAR_BITS */ #include /* for uintptr_t */ -#include "internal/compilers.h" /* for MSC_VERSION_SINCE */ +#include "internal/compilers.h" /* for __has_builtin */ #ifdef _MSC_VER # include /* for _byteswap_uint64 */ From f49b514ce166faf68bf333f73c792390259b559f Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 25 Sep 2026 16:40:03 +0900 Subject: [PATCH 10/15] win32.h: Use stdint.h for intptr_t on mswin too The fallback definitions were for Visual C++ 2008 and older, which had no stdint.h. Co-Authored-By: Claude Opus 5.5 --- include/ruby/win32.h | 36 +----------------------------------- 1 file changed, 1 insertion(+), 35 deletions(-) diff --git a/include/ruby/win32.h b/include/ruby/win32.h index ae11a61481e74e..e7274cc93865e3 100644 --- a/include/ruby/win32.h +++ b/include/ruby/win32.h @@ -65,41 +65,7 @@ extern "C++" { /* template without extern "C++" */ #endif #include #include -#if defined __MINGW32__ -# include -#else -# if !defined(_INTPTR_T_DEFINED) -# ifdef _WIN64 -typedef __int64 intptr_t; -# else -typedef int intptr_t; -# endif -# define _INTPTR_T_DEFINED -# endif -# if !defined(INTPTR_MAX) -# ifdef _WIN64 -# define INTPTR_MAX 9223372036854775807I64 -# else -# define INTPTR_MAX 2147483647 -# endif -# define INTPTR_MIN (-INTPTR_MAX-1) -# endif -# if !defined(_UINTPTR_T_DEFINED) -# ifdef _WIN64 -typedef unsigned __int64 uintptr_t; -# else -typedef unsigned int uintptr_t; -# endif -# define _UINTPTR_T_DEFINED -# endif -# if !defined(UINTPTR_MAX) -# ifdef _WIN64 -# define UINTPTR_MAX 18446744073709551615UI64 -# else -# define UINTPTR_MAX 4294967295U -# endif -# endif -#endif +#include #ifndef __MINGW32__ # define mode_t int #endif From 6c5cfbc9362722c962bef3b38c92010e46b9538c Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 25 Sep 2026 16:41:12 +0900 Subject: [PATCH 11/15] regint.h: Remove the PRIdPTR fallback It was for Visual C++ 2012 and older, which had no inttypes.h. Co-Authored-By: Claude Opus 5.5 --- regint.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/regint.h b/regint.h index f9df9019ef5b38..7f8e5f60bd6564 100644 --- a/regint.h +++ b/regint.h @@ -264,18 +264,6 @@ # include #endif -#ifndef PRIdPTR -# ifdef _WIN64 -# define PRIdPTR "I64d" -# define PRIuPTR "I64u" -# define PRIxPTR "I64x" -# else -# define PRIdPTR "ld" -# define PRIuPTR "lu" -# define PRIxPTR "lx" -# endif -#endif - #ifndef PRIdPTRDIFF # define PRIdPTRDIFF PRIdPTR #endif From 047cd2fd272720d97c85d62849c572aae7b9fc89 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 25 Sep 2026 16:41:39 +0900 Subject: [PATCH 12/15] Remove the _aligned_malloc prototype for old Visual C++ malloc.h, which win32.h includes, declares it. Co-Authored-By: Claude Opus 5.5 --- gc/default/default.c | 1 - 1 file changed, 1 deletion(-) diff --git a/gc/default/default.c b/gc/default/default.c index 8c57effedf7135..649292d49b3f73 100644 --- a/gc/default/default.c +++ b/gc/default/default.c @@ -2567,7 +2567,6 @@ gc_aligned_malloc(size_t alignment, size_t size) #if defined __MINGW32__ res = __mingw_aligned_malloc(size, alignment); #elif defined _WIN32 - void *_aligned_malloc(size_t, size_t); res = _aligned_malloc(size, alignment); #elif defined(HAVE_POSIX_MEMALIGN) if (posix_memalign(&res, alignment, size) != 0) { From 75d54670397c777f7898a92d4a39a49225065d60 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Wed, 16 Sep 2026 20:41:33 +0900 Subject: [PATCH 13/15] Ignore EACCES when unlinking a tempfile from the finalizer On Windows, File.unlink raises Errno::EACCES while another handle still holds the file open. Tempfile#unlink already ignores that, but FinalizerManager#call only rescued ENOENT, so the exception escaped from the GC finalizer and was reported on stderr. Co-Authored-By: Claude Fable 5.1 --- lib/tempfile.rb | 2 +- test/test_tempfile.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/tempfile.rb b/lib/tempfile.rb index cd512bb1c5224b..1f29ad8ce23ff6 100644 --- a/lib/tempfile.rb +++ b/lib/tempfile.rb @@ -390,7 +390,7 @@ def call(object_id) $stderr.puts "removing #{@path}..." if $DEBUG begin File.unlink(@path) - rescue Errno::ENOENT + rescue Errno::ENOENT, Errno::EACCES end $stderr.puts "done" if $DEBUG end diff --git a/test/test_tempfile.rb b/test/test_tempfile.rb index 8077cc3603f8b7..a43ba28117ef47 100644 --- a/test/test_tempfile.rb +++ b/test/test_tempfile.rb @@ -235,6 +235,20 @@ def test_finalizer_does_not_unlink_if_already_unlinked end end unless /mswin|mingw/ =~ RUBY_PLATFORM + def test_finalizer_ignores_eacces_on_unlink + assert_in_out_err("-r#{LIB_TEMPFILE_RB_PATH}", <<~'RUBY') do |(filename,*), (error,*)| + def File.unlink(*) + raise Errno::EACCES + end + file = Tempfile.new("foo") + puts file.path + RUBY + assert_file.exist?(filename) + File.unlink(filename) + assert_nil error + end + end + def test_close_does_not_make_path_nil t = tempfile("foo") t.close From b5245a5d33d11e6fd0d90f7572ccbd8ab83b643a Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 25 Sep 2026 18:00:10 +0900 Subject: [PATCH 14/15] Stub File.unlink without redefining it in the tempfile test Redefining the method warns under RUBYOPT=-w, which CI uses, and the test expects nothing on stderr. Prepending a module leaves the original method in place. Co-Authored-By: Claude Opus 5.5 --- test/test_tempfile.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/test_tempfile.rb b/test/test_tempfile.rb index a43ba28117ef47..91cb1a8882fdd1 100644 --- a/test/test_tempfile.rb +++ b/test/test_tempfile.rb @@ -237,9 +237,11 @@ def test_finalizer_does_not_unlink_if_already_unlinked def test_finalizer_ignores_eacces_on_unlink assert_in_out_err("-r#{LIB_TEMPFILE_RB_PATH}", <<~'RUBY') do |(filename,*), (error,*)| - def File.unlink(*) - raise Errno::EACCES - end + File.singleton_class.prepend(Module.new do + def unlink(*) + raise Errno::EACCES + end + end) file = Tempfile.new("foo") puts file.path RUBY From da3e1fcb685864a2f58f113e82d9dc67d7fe9197 Mon Sep 17 00:00:00 2001 From: aadi Date: Fri, 25 Sep 2026 03:46:47 +0000 Subject: [PATCH 15/15] Fix init_is_float bug --- array.c | 2 +- test/ruby/test_array.rb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/array.c b/array.c index f84f7ae3b91659..d8e8f2ac31cf12 100644 --- a/array.c +++ b/array.c @@ -8403,7 +8403,7 @@ rb_ary_sum(int argc, VALUE *argv, VALUE ary) not_exact: v = finish_exact_sum(n, r, v, i!=0); - if (init_is_float ? (--i, e = argv[0], true) : RB_FLOAT_TYPE_P(e)) { + if (init_is_float || RB_FLOAT_TYPE_P(e)) { /* * Kahan-Babuska balancing compensated summation algorithm * See https://link.springer.com/article/10.1007/s00607-005-0139-x diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index e9fd6508920d29..935a56452eb3d8 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -3752,6 +3752,11 @@ def test_sum assert_float_equal(8.5, [3.5, 5].sum) assert_float_equal(10.5, [2, 8.5].sum) assert_float_equal(1_000 * 0.1, Array.new(1_000, 0.1).sum(0.0)) + + # Init with a float, but start with some fixnums in the array. + # Tests compensated summation fallthrough in array.c + assert_float_equal(5.0, [1, 1, 1.0, 1.0, 1.0].sum(0.0)) + assert_float_equal((FIXNUM_MAX+1).to_f, [FIXNUM_MAX, 1, 0.0].sum) assert_float_equal((FIXNUM_MAX+1).to_f, [0.0, FIXNUM_MAX+1].sum) @@ -3769,6 +3774,19 @@ def test_sum assert_float_equal(12.0, ary.sum {|x| yielded << x; x * 2 }) assert_equal(ary, yielded) + yielded_ctr = 0 + result = %w[a b].sum(0) do + yielded_ctr += 1 + end + assert_equal(result, 3) + + yielded_ctr = 0.0 + result = %w[a b].sum(0.0) do + yielded_ctr += 1 + yielded_ctr.to_f + end + assert_equal(result, 3.0) + assert_raise(TypeError) { [Object.new].sum } large_number = 100000000