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

ObjectSpace is disabled; each_object will only work with Class #4619

Closed
ioquatix opened this issue May 22, 2017 · 6 comments
Closed

ObjectSpace is disabled; each_object will only work with Class #4619

ioquatix opened this issue May 22, 2017 · 6 comments
Milestone

Comments

@ioquatix
Copy link
Contributor

Environment

https://travis-ci.org/socketry/async-rspec/jobs/234686073

all_ios = ObjectSpace.each_object(IO).to_a.sort_by(&:object_id)

Expected Behavior

It should work.

Actual Behavior

It fails: ObjectSpace is disabled; each_object will only work with Class, pass -X+O to enable

Either the error message is not clear - IO is a class, or something is wrong with JRuby.

What is the best way to make this work? Keep in mind, I need to run this in several different gems, so I'd like to avoid JRuby specific configuration in EVERY gem that's running on travis.

@headius
Copy link
Member

headius commented May 22, 2017

I think the error message is actually quite clear. Without passing a flag, it works only with "Class", not "a class". This is because walking all classes in the system is easy:we start at BasicObject and walk every descendant, which eventually traverses all Class instances in the system.

Perhaps we should put Class in quotes so it will be interpreted more literally.

In any case, we will not be expanding that because there's no easy way to walk all heap objects on the JVM without switching to a debug mode. You'll need to pass the flag or find another way to accomplish what you are doing. Im happy to help with that.

Why do you need to walk all IO in the system?

@ioquatix
Copy link
Contributor Author

Thanks for the quick reply and the offer to help.

It's used to ensure that IOs are not being leaked.

The exact code is here:

https://github.com/socketry/async-rspec/blob/master/lib/async/rspec/leaks.rb

If you have some ideas of a better way to do this, that would be awesome.

Ideally, we don't need to supply Ruby specific flags to make this work.

@kares
Copy link
Member

kares commented May 22, 2017

seems you're trying to solve IO-leaks in Ruby land ... that whole part is heavily MRI specific.
JRuby has decided to disable GC.start (its a no-op) since it does more harm than good ... if used in gems

@ioquatix
Copy link
Contributor Author

I'm not trying to solve them, I'm trying to detect them. If the code being tested is leaking IO objects, it's something wrong with the design of the code. It's important to pick this up as soon as possible. This wasn't done until late in the game in celluloid-io and it was a huge PITA to fix up.

@kares
Copy link
Member

kares commented May 23, 2017

@ioquatix yy - that's what I meant ... great that you had some success but on the JVM there's going to be potentially a lot of IOs outside of Ruby land (e.g. if there's an extension involved), even if you run with the -X+O option, so I am not sure its a good solution in general. meaning that JRuby won't do anything about it, you're just lucky there's an (unfortunate) API for it in MRI 😈 ... its more of a task for tooling/monitoring

@ioquatix
Copy link
Contributor Author

We've added the appropriate env so object space continues to work.

https://travis-ci.org/socketry/async/jobs/267435348/config

@kares kares added this to the Won't Fix milestone Aug 23, 2017
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

3 participants