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

RB_GC_GUARD to protect from premature GC #263

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@johnsyweb
Contributor

johnsyweb commented Dec 23, 2015

Context

I have been auditing some third-party Gems for memory errors in our app, which I believe are caused by premature GC in C extensions.

Change

In static void convert_UTF8_to_JSON_ASCII(FBuffer *, VALUE), string is passed by value but isn't referenced after we take a pointer to it (source), so could be optimised away after that. A new Exception object being raised could cause a GC to clean up string, invalidating source. I introduce RB_GC_GUARD(string); later in the function to prevent this.

static int isArrayOrObject(VALUE) looks safe to me at the moment, but I've added the guard just-in-case. Should an exception be introduced, this would have the same issue as above.

@johnsyweb

This comment has been minimized.

Contributor

johnsyweb commented Dec 23, 2015

The build failures in are due to third-party gems not being available for those rubies (e.g: Gem::InstallError: tins requires Ruby version >= 2.0.).

Should we address that in a separate PR?

@johnsyweb

This comment has been minimized.

Contributor

johnsyweb commented Dec 28, 2016

@flori: Why was this closed? Did I miss some information from the PR?

@johnsyweb

This comment has been minimized.

Contributor

johnsyweb commented Dec 28, 2016

Never mind, I see this was included as d5115ed .

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment