Skip to content

Possible ChannelFD leak in FilenoUtil? #4796

@seanguo

Description

@seanguo

Environment

JRuby 9.1.13.0
Linux
Using as embedded JSR223 engine

We upgraded from 1.7.21 to 9.1.13.0 to try to address the issue in #4446. But after a simple load test we found that the map in FilenoUtil is accumulating during the test. So I wrote the following simple script to try to reproduce:

Sample Code Snippet

public class Test {
  public static void main(String[] args) throws InterruptedException, ScriptException, ClassNotFoundException, IOException {
    ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
    final ScriptEngine engine = scriptEngineManager.getEngineByName("jruby");
    final ScriptContext scriptContext = new SimpleScriptContext();
    scriptContext.setAttribute("org.jruby.embed.termination", true, ScriptContext.ENGINE_SCOPE);

    engine.eval("print 'test\n'", scriptContext);

    System.gc();
    Thread.sleep(5000);

    System.out.println(Ruby.getGlobalRuntime().getFilenoUtil().getNumberOfWrappers());

  }
}

Unexpected Behavior

I got the following output:
test
3
Shouldn't the number be 0?

Is this an issue of the new code or my usage is incorrect for the new update?
Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions