Skip to content

NPE in PythonLanguage#isThreadAccessAllowed #120

@fniephaus

Description

@fniephaus

When requesting Python code evaluation in a Ruby application, which uses multithreading, a NPE is raised in PythonLanguage. The reason for this seems to be that isWithThread is only set in PythonLanguage#createContext and it looks like this is not being called before the code evaluation.

Line of interest

https://github.com/graalvm/graalpython/blob/52ef933f7f76661b40841f00df056a9980d12871/graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java#L547

Example Stack trace

Internal error occurred: org.graalvm.polyglot.PolyglotException: org.truffleruby.language.control.RaiseException: <no message> (NullPointerException)
        from com.oracle.graal.python.PythonLanguage.isThreadAccessAllowed(PythonLanguage.java:547)
        from com.oracle.truffle.api.LanguageAccessor$LanguageImpl.isThreadAccessAllowed(LanguageAccessor.java:233)
        from com.oracle.truffle.polyglot.PolyglotLanguageContext.checkThreadAccess(PolyglotLanguageContext.java:269)
        from com.oracle.truffle.polyglot.PolyglotLanguageContext.ensureCreated(PolyglotLanguageContext.java:452)
        from com.oracle.truffle.polyglot.PolyglotLanguageContext.ensureInitialized(PolyglotLanguageContext.java:531)
        from com.oracle.truffle.polyglot.PolyglotContextImpl.getContextInitialized(PolyglotContextImpl.java:362)
        from com.oracle.truffle.polyglot.EngineAccessor$EngineImpl.parseForLanguage(EngineAccessor.java:194)
        from com.oracle.truffle.api.TruffleLanguage$Env.parsePublic(TruffleLanguage.java:1931)
        from org.truffleruby.interop.PolyglotNodes$EvalFileNode.eval(PolyglotNodes.java:128)
        from org.truffleruby.interop.PolyglotNodes$EvalFileNode.evalFile(PolyglotNodes.java:122)
        from org.truffleruby.interop.PolyglotNodesFactory$EvalFileNodeFactory$EvalFileNodeGen.executeAndSpecialize(PolyglotNodesFactory.java:354)
        from org.truffleruby.interop.PolyglotNodesFactory$EvalFileNodeFactory$EvalFileNodeGen.execute(PolyglotNodesFactory.java:336)
        from org.truffleruby.language.control.SequenceNode.execute(SequenceNode.java:35)
        from org.truffleruby.language.methods.ExceptionTranslatingNode.execute(ExceptionTranslatingNode.java:32)
        from org.truffleruby.language.LazyRubyNode.execute(LazyRubyNode.java:43)
        from org.truffleruby.language.RubyRootNode.execute(RubyRootNode.java:
...

/cc @janehmueller

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions