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

hiredis-rb is not GC-safe #42

Open
findchris opened this issue Oct 13, 2015 · 26 comments
Open

hiredis-rb is not GC-safe #42

findchris opened this issue Oct 13, 2015 · 26 comments
Milestone

Comments

@findchris
Copy link

Hi there.

While investigating a GC-related issue (ohler55/oj#265 (comment)), @ohler55 mentioned that he looked at the hiredis-rb C code and saw some stuff that wasn't GC safe and might be the source of the bug I'm investigating (NotImplementedError: method ... called on terminated object). He pointed out that:

Ruby checks the stack for VALUE types which are Ruby object references. Compilers often optimize code by placing variable in registers which are invisible to Ruby as far as checking for wether an object is still being referenced. The work around for this is to make sure all VALUE local variable are volatile. That keeps them out of registers and on the stack.

See the linked-to github issue above, but I'm only seeing this issue a few times per day on an app that gets significant traffic, so it's tough to reproduce, but all signs point to it being GC-related.

I look forward to your reply here.

@badboy badboy self-assigned this Oct 14, 2015
@badboy
Copy link
Contributor

badboy commented Oct 14, 2015

Thanks for the report. I'm quite busy this and the coming week, but I will look into this.

@findchris
Copy link
Author

Thanks @badboy - At first read, does the addition of volatile to the VALUEs make sense?

@findchris
Copy link
Author

@badboy - Get a chance to look at this?

@findchris
Copy link
Author

@badboy Is there anyone else I can @tag here to get a set of eyes on this issue?

@badboy
Copy link
Contributor

badboy commented Oct 31, 2015

Hey. Currently I'm the only maintainer, so there's no one else to take a look.
But I did and it seems there is a macro to use (RB_GC_GUARD) on those VALUEs instead of making it explicitely volatile.

I'm trying to find the right solution today.

@badboy
Copy link
Contributor

badboy commented Oct 31, 2015

@findchris Do you have a test case that triggers the bug reliably? Would be nice to know that any fix we apply actually solves the problem (the other option for me would be to read the assembly and I'm really not good at that)

@findchris
Copy link
Author

@badboy I don't have a test case, sadly. It seems to be GC-related, and I have been able to reproduce consistently.

@ohler55 Did this comment make sense to you? I just don't know enough to respond intelligently.

@findchris
Copy link
Author

@badboy and @ohler55 - Any chance to check this out, or is it dying on the vine here?

@ohler55
Copy link
Contributor

ohler55 commented Nov 15, 2015

Glad to get involved. Do you have a set of changes? Need a some help and a PR?

@badboy
Copy link
Contributor

badboy commented Nov 15, 2015

I don't have any code yet.
I can't even reproduce it, which makes it near to impossible to know if any change would actually cover the bug. I appreciate all help, so if you have more insight or know your way around in Ruby extensions (I really don't :D) please tell so.

@ohler55
Copy link
Contributor

ohler55 commented Nov 15, 2015

ok, I'll put together some change and attempt to put together a test. It will be a step at a time.

@badboy
Copy link
Contributor

badboy commented Nov 15, 2015

Thanks in advance!

@findchris
Copy link
Author

Thanks guys; I really appreciate you stepping up on this @ohler55 👏

@ohler55
Copy link
Contributor

ohler55 commented Nov 18, 2015

I am not having much success reproducing the failure here. @findchris, can you run tests on changes we make to verify when the changes work? You can be our tester. Less than ideal but it should be enough.

@findchris
Copy link
Author

I can lock production to a particular commit, which should work.

@ohler55
Copy link
Contributor

ohler55 commented Nov 19, 2015

It would help a lot. I put up a PR. Maybe batboy can help get everything squared away on branches.

@findchris
Copy link
Author

Thanks @ohler55.
@badboy Can you look at #43?

@findchris
Copy link
Author

@badboy Did you get a chance to review #43?

@findchris
Copy link
Author

Checking in @badboy #squeakywheel

@badboy
Copy link
Contributor

badboy commented Dec 3, 2015

I'm sorry this is post-poned so long, but I have to shift it a bit again (upcoming holiday and I just need a break from this). I take a fresh look when I'm back in 2 weeks.

@findchris
Copy link
Author

Totally understandable. Enjoy your holiday!

@badboy badboy added this to the 1.0.0 milestone Dec 29, 2015
@findchris
Copy link
Author

This is still an issue for us.

@badboy - Did you get a chance to look at this issue?

@badboy
Copy link
Contributor

badboy commented Apr 7, 2017

I merged, but never pushed a new release. Will take care of that ASAP

@badboy badboy removed their assignment Feb 18, 2018
@mberlanda
Copy link

Hey there! Did anyone managed to reproduce the issue described by @findchris since the latest release? Is it still open?

@tonydehnke
Copy link

Bump - what is the status of this @badboy?

Should this be closes or is this still an issue?

@badboy
Copy link
Contributor

badboy commented Oct 9, 2019

I'm not working on hiredis-rb anymore.

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

No branches or pull requests

5 participants