Skip to content

Free Ruby-allocated memory with xfree - #88

Merged
hsbt merged 2 commits into
masterfrom
claude/mswin-head-segv-a66493
Nov 26, 2026
Merged

hsbt merged 2 commits into
masterfrom
claude/mswin-head-segv-a66493

Conversation

@hsbt

@hsbt hsbt commented Nov 26, 2026

Copy link
Copy Markdown
Member

The mswin job on ruby-head stops with rake aborted! and SignalException: SIGSEGV before any test output, as on #86 and #87. Even ruby -e 'require "win32ole"' exits with 0xC0000374 there.

The mswin ruby-head binaries are now built with --with-mimalloc, so ruby_xmalloc allocates from mimalloc, and NEWS notes that freeing it with free crashes. This extension freed memory from ALLOC, ALLOC_N and TypedData_Make_Struct with the CRT free, and olevariant_free on the WIN32OLE::Variant constants corrupted the heap at exit. This uses xfree instead.

I ran bundle exec rake on Windows with ruby 4.1.0dev 3288e455a0 and 42a644f6e0 (both mimalloc) and with 4.0.10. Each run gave 225 tests, 0 failures.

Generated with Claude Code

hsbt and others added 2 commits November 26, 2026 18:50
ruby-head on mswin now allocates ruby_xmalloc and its family with mimalloc when built with --with-mimalloc, which the mswin binaries are. The CRT free in olevariant_free then corrupted the heap at exit, so even `require "win32ole"` ended with 0xC0000374. Every free here releases memory from ALLOC, ALLOC_N or TypedData_Make_Struct.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The bare `mswin` only follows ruby-head, so the released mswin build was not tested at all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hsbt
hsbt merged commit 3d07656 into master Nov 26, 2026
30 checks passed
@hsbt
hsbt deleted the claude/mswin-head-segv-a66493 branch November 26, 2026 10:11
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