GithubHelp home page GithubHelp logo

Comments (3)

mxro avatar mxro commented on July 21, 2024

Hi Bhanu, it has not been designed specifically to be thread-safe so I would recommend rather not doing it.

That being said, be welcome to have a look through the code and check if there are any non-thread safe operations!

from delight-nashorn-sandbox.

hyperpape avatar hyperpape commented on July 21, 2024

It appears to me that produceSecureBindings has a thread safety issue.

                cached = scriptEngine.getBindings(ScriptContext.ENGINE_SCOPE);
                sanitizeBindings(cached);
                if (!allowExitFunctions) {
                    sb.append("var quit=function(){};var exit=function(){};");
                }
                if (!allowPrintFunctions) {
                    sb.append("var print=function(){};var echo = function(){};");
                }
                if (!allowReadFunctions) {
                    sb.append("var readFully=function(){};").append("var readLine=function(){};");
                }
                if (!allowLoadFunctions) {
                    sb.append("var load=function(){};var loadWithNewGlobal=function(){};");
                }
                if (!allowGlobalsObjects) {
                    // Max 22nd of Feb 2018: I don't think these are strictly necessary since they are only available in scripting mode
                    sb.append("var $ARG=null;var $ENV=null;var $EXEC=null;");
                    sb.append("var $OPTIONS=null;var $OUT=null;var $ERR=null;var $EXIT=null;");
                }
                scriptEngine.eval(sb.toString());

                resetEngineBindings();

cached is instantiated and then mutated, but there is no guarantee that multiple threads are not within in this same block at once (or even that one thread will see engineAsserted = true before it sees cached set).

from delight-nashorn-sandbox.

mxro avatar mxro commented on July 21, 2024

@hyperpape Thank you for finding this. Could you raise a separate issue for this so we can track it there and fix it? Thank you!

from delight-nashorn-sandbox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.