Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Michael[tm] Smith
    @sideshowbarker
    but for anybody else like me who’s trying to run it under Nashorn, they are almost certainly going to hit this same problem
    Ingvar Stepanyan
    @RReverser
    Oh wow it actually runs same JS environment multi-threaded?
    Michael[tm] Smith
    @sideshowbarker
    yup
    crazy, huh?
    I have no idea what magic Nashorn/Java have for doing that
    but it works
    most of the time it works without you needing to do any manual thread management in the wrapping Java code
    but in some cases like mine — running it in a servlet environment where it gets hit with something like 2.5 requests per second — then you start needing to deal with synchronization and locks
    and FYI what I’m using this for is the W3C HTML Checker (HTML5 validator)
    Michael[tm] Smith
    @sideshowbarker
    to do JavaScript-syntax checking of all contents of script elements, and on*- event-handler attributes, and the pattern attribute and all javacript:-protocol URLs (e.g., <a href> values)
    Ingvar Stepanyan
    @RReverser
    It just sounds crazy and a bit complicated at the same time - I wonder if it gives any wins versus running several independent processes (or at least independent engine instances)
    Anyway, I'm not sure what to answer about this on-topic given that it's outside of Acorn's domain...
    Michael[tm] Smith
    @sideshowbarker
    @RReverser yeah it’s not a problem in Acorn
    but I’m just curious to investigate if there might be a way to work around it by making some change to Acorn
    because as I said earlier, what’s interesting about it is that it always fails in that one same call
    and if I “fix” that call by replacing the skipWhiteSpace reference with the regex literal it references, then the rest of the code always runs to completion without any failures
    that is not intuitively what I would expect if the cause were a general problem with how the code is run in a multithreaded environment, and not even intuitively what I would expect if the cause were a more-specific problem (bug) in the (Nashorn) RegExp implementation
    Michael[tm] Smith
    @sideshowbarker
    in other words, it seems like there’s something “different” about the state that exists when that one particular skipWhiteSpace.exec call is made
    and I mean “different” in terms of the acorn state — different from any other places in the code where skipWhiteSpace.exec is called
    but anyway, at this point it’s more just about my personal software-engineering curiosity than about trying to solve any real problem
    Ingvar Stepanyan
    @RReverser

    Do you have Java version & full stacktrace by any chance? I'm not familiar with Nashorn at all, but this from quick googling sounds suspiciously similar: http://nashorn.36665.n7.nabble.com/ArrayIndexOutOfBoundsException-and-NPE-in-regexp-Code-td3139.html

    We've run into a few cases where Joni (regex) is not safe across threads. This has been fixed in 8u20 http://hg.openjdk.java.net/jdk8u/jdk8u-dev/nashorn/rev/9ad26ed8cc97 . The workaround is to use new RegExp("...") so that the regexp is not shared. If you are iterating through a loop, hoist the expression outside the loop.

    @sideshowbarker ^
    Michael[tm] Smith
    @sideshowbarker
    @RReverser thanks will look
    and will grab a copy of the stacktrace and paste somewhere and link to here
    java version "1.8.0_162"
    The workaround is to use new RegExp("...") so that the regexp is not shared
    will hack my acorn copy to do that, and see if it makes any difference
    Michael[tm] Smith
    @sideshowbarker
    OK, no, that didn’t fix it
    but thanks much — that gives me some other ideas
    also, I haven’t tried running the code under Java9 yet (just been testing in a Java8 environment), and I think they made some significant changes to Nashorn in Java9, and perhaps this problem won’t be reproducible under Java9 and if so that’ll be another data point to help track down if it’s a bug in Nashorn, and where
    Michael[tm] Smith
    @sideshowbarker
    but anyway, as far as the stack trace: My code never throws an unexpected Java exception — instead it just catches a JavaScript TypeError that acorn throws
    so it seems it‘s a different cause/bug then the one reported at http://nashorn.36665.n7.nabble.com/ArrayIndexOutOfBoundsException-and-NPE-in-regexp-Code-td3139.html
    Ingvar Stepanyan
    @RReverser
    Hm okay, was worth a shot
    Michael[tm] Smith
    @sideshowbarker
    yeah, thanks
    it really does seem like it’s just a bug in Nashorn
    so I plan to write up an e-mail message to that Nashorn mailing list when I can make time
    Ingvar Stepanyan
    @RReverser
    Yeah just wondering if it's fixed yet and what would be minimal way to reproduce (Acorn does lots of things)
    Might be worth reporting it
    Oh ok great
    Michael[tm] Smith
    @sideshowbarker
    yeah
    yeah I’m going to make a reduced program (class) to point them to
    the only wrinkle is that to reproduce it they’ll need to run it in a way that ensures it’s getting called by multiple threads concurrently, but I assume they have some way to do that when testing
    Ingvar Stepanyan
    @RReverser
    I guess you can just start several threads with while(true)?
    Michael[tm] Smith
    @sideshowbarker
    sure yeah
    but myself locally I’ve just been hitting it with Apache Benchmark
    that only works if it’s run at an HTTP URL (e.g., within a servlet)
    anyway, all that aside, I am super happy with Acorn
    very nice piece of work
    and really nice to have the new Unicode regex stuff that landed recently
    (support for the /u flag, etc.)