Skip to content

Fix Semian resource allocator pairing#1042

Merged
rwstauner merged 1 commit into
mainfrom
rwstauner/less-crashy
May 27, 2026
Merged

Fix Semian resource allocator pairing#1042
rwstauner merged 1 commit into
mainfrom
rwstauner/less-crashy

Conversation

@rwstauner

@rwstauner rwstauner commented May 23, 2026

Copy link
Copy Markdown
Contributor

Ruby headers redefine strdup to ruby_strdup, so res->name was allocated with Ruby's allocator even though it looked like libc strdup. Free it with xfree instead of free, and make the allocation explicit with ruby_strdup.

Also release the malloc'd strkey field and add GC regression coverage for native resource cleanup.

@jhawthorn jhawthorn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks right to me!

@rwstauner rwstauner force-pushed the rwstauner/less-crashy branch 2 times, most recently from 0262eac to 89cb5be Compare May 26, 2026 22:51
Ruby headers redefine strdup to ruby_strdup in C extensions, so res->name was allocated with Ruby's allocator even though it looked like libc strdup. Free it with xfree instead of free, and make the allocation explicit with ruby_strdup.

Also release the malloc'd strkey field and add GC regression coverage for native resource cleanup.
@rwstauner rwstauner force-pushed the rwstauner/less-crashy branch from 89cb5be to 8578234 Compare May 26, 2026 23:03
@rwstauner rwstauner merged commit 7f72ed4 into main May 27, 2026
35 checks passed
@rwstauner rwstauner deleted the rwstauner/less-crashy branch May 27, 2026 17:07
@rwstauner rwstauner self-assigned this May 27, 2026
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.

2 participants