validator/grunt-html

java.lang.StackOverflowError when running

lagrz opened this issue · 16 comments

Hey guys im getting a java.lang.StackOverflowError error whenever I run the grunt task here's my config:

htmllint: {
    all: ["html/index.html"]
}

I'm currently running Java 7 update 51 on windows.

Can you provide some more information? What's the full output? What version of the plugin are you using? Do you get the same error when running vnu.jar directly? If that's the case, you should report the issue over there.

"grunt-html": "~1.2.0"

Here is the full output

From the looks of it, the vnu.jar file is the one throwing the errors. Thanks for directing to the right place

Are absolutely certain you have Java 7? This looks like the error you get when running it with Java 6

I have java 7 update 51

I think java might need to be called with -Xss512k.
It's also probably good to call it with -XX:ThreadStackSize=2048.

@lagrz can you test with those extra arguments on your local copy? need to add them here: https://github.com/jzaefferer/grunt-html/blob/d96f01c9b8d95ec7c89c8e1e4cf12ee0a25b5972/lib/htmllint.js#L14

Success! Works with added flags.

Interesting!!

Should we add those flags or leave it to developers of affected machines to configure their Java with environment variables?

I believe this is only an issue for 32 bit OSes. @lagrz are you on a 32 bit OS?

You can also fix it by adding to your JAVA_OPTS environment variable

Yes im on a 32 bit OS

The part of the validator code that reads and evaluates the HTML5 schema seems to need a minimum stack size of 512k. On 64-bit systems, I think java uses a default stack size of 1024k, so on those systems it doesn't need to be adjusted for the validator. But I think the java default stack size on, e.g., 32-bit Windows, is only 320k, so it will definitely be a problem there.

FWIW, I think it'd be sane for grunt-html to just invoke java with -Xss512k. As far as I can tell, the validator will still run fine on 64-bit systems with that setting, and I think the may have the added advantage of using less memory—because it doesn't actually need 1024k for each thread. (Actually I think whatever thread handles the schema evaluation is the only one that even needs 512k; whatever other threads are getting run probably don't even need nearly that much.)

@sideshowbarker looks like it might need 1024k, now the error that was happening now is happening on 64 bits. Setting the stack size to 1024 fixes it.

@LaurentGoderre FYI, earlier today and tonight I ran npm install and grunt on fully up-to-date local clones of wet-boew/wet-boew master on my workstation (Windows 7 64-bit + Java 6 32-bit) and my home computer (Windows 7 64-bit + Java 7 64-bit). Didn't run into any issues with grunt-html's 512k parameter from pull #25.

Anyways, I'm not against 1024k so long as it doesn't re-introduce any problems in XP 32-bit :P.