Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate string type when constructing IO::Buffer for string mapping. #5115

Merged
merged 1 commit into from
Nov 16, 2021

Conversation

ioquatix
Copy link
Member

@ioquatix ioquatix commented Nov 15, 2021

You need to check it's actually a String before calling this.
And also you need to pin it to avoid it moving when GC.compact/autocompact is used.

@ioquatix
Copy link
Member Author

@tenderlove how do you pin an object, in this case source so it can be moved? Do we need to do something special?

@ioquatix ioquatix changed the title Validate string type when constructing IO::Buffer for string mapping. Validate string type when constructing IO::Buffer for string mapping. Nov 15, 2021
@ioquatix ioquatix merged commit 5190926 into ruby:master Nov 16, 2021
@ioquatix ioquatix deleted the io-buffer-string-fixes branch November 16, 2021 21:39
@eregon
Copy link
Member

eregon commented Dec 18, 2021

I found ruby/fiddle#44 but I'm not sure how to apply it for this case, cc @tenderlove

@ioquatix
Copy link
Member Author

We already have:

void
rb_io_buffer_type_mark(void *_data)
{
    struct rb_io_buffer *data = _data;
    rb_gc_mark(data->source);
}

Is it enough? How do we handle moving?

@tenderlove
Copy link
Member

@ioquatix rb_gc_mark will already pin it, so we don't need to worry.

@ioquatix
Copy link
Member Author

@tenderlove thank you so much, it's really helpful to have your advice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants