svenkreiss / html5validator

Command line tool to validate HTML5 files. Great for continuous integration.
MIT License
319 stars 34 forks source link

Stack Overflow #10

Closed DanielOaks closed 8 years ago

DanielOaks commented 8 years ago

I've been running into an issue occasionally while running it, getting this error:

$ html5validator --root _site/
WARNING:html5validator.validator:StackOverflowError while evaluating HTML schema.
The checker requires a java thread stack size of at least 512k.
Consider invoking java with the -Xss option. For example:

  java -Xss512k -jar ~/vnu.jar FILE.html

One of the systems I've been getting this bug on is a bad little notebook with not-that-much RAM, but the other is a MBP with 16GB of RAM. Figured I'd ask and see if you've seen this before :)

Thanks for the awesome and useful tool!

edit: Hmm, upping the call to use -Xss2048k as recommended did work. Maybe it'd be nice to allow for these sort of higher limits as a command-line option or something?

Supuhstar commented 8 years ago

That must be quite the webpage! Perhaps trim it down a bit, too? ;)

svenkreiss commented 8 years ago

@DanielOaks Thanks for bringing this up. I had not seen this problem. I like the idea of making it a command line option.

DanielOaks commented 8 years ago

I can imagine something like a -b option (big) that doubles the memory size each time it's added, maybe something like: html5validator -bb doubling it from 512 to 1024, then from 1024 to 2048? Similar to how multiple levels of verbosity/debugging flags work in some programs.

Otherwise just a simple way of specifying the size manually, --size 2048k or something simple like that?

@Supuhstar Unfortunately, pages describing technical data can get pretty big :)

svenkreiss commented 8 years ago

I like the -b, -bb, -bbb approach. Nobody knows in any case which file size corresponds to which stack size. Makes this feature more accessible.

php-coder commented 8 years ago

How I can workaround this? How to specify the stack size?

php-coder commented 8 years ago

P.S. Answering to myself:

--- /usr/lib/python2.7/site-packages/html5validator/validator.py.orig   2016-01-13 18:06:41.974810572 +0100
+++ /usr/lib/python2.7/site-packages/html5validator/validator.py    2016-01-13 18:06:57.563825066 +0100
@@ -68,7 +68,7 @@
                 raise JavaNotFoundException()

         try:
-            o = subprocess.check_output(['java', '-Xss512k', '-jar',
+            o = subprocess.check_output(['java', '-jar',
                                          self.vnu_jar_location] + opts + files,
                                         stderr=subprocess.STDOUT,
                                         ).decode('utf-8')
svenkreiss commented 8 years ago

@php-coder Interesting. Is this on Windows?

I was under the impression that specifying '-Xss512k' would always increase the stack size (from 128k or 320k). For you however it seems to increase when you remove it. I am not sure, but I found some reference online that on Windows the default is actually 1024k.

php-coder commented 8 years ago

@svenkreiss No, it's on Fedora 22 with OpenJDK 1.8.0_60

php-coder commented 8 years ago

It also fail in TravisCI with the same error :-( Probably, it's because I still use old build type...

svenkreiss commented 8 years ago

Working on this. The 0.2 branch contains a fix for this. It contains the new command line options -l, -ll and -lll which increase the stack size. It also contains an update of the underlying Java checker. Unfortunately, that now requires Java 8. I updated the readme in the 0.2 branch with instructions.

Any volunteers to test this branch? Unit tests are passing. I think you can install this branch directly with pip install https://github.com/svenkreiss/html5validator/zipball/0.2.

php-coder commented 8 years ago

I'll try it when I will have a time..

svenkreiss commented 8 years ago

Thank you all!

Version 0.2.1 is now released and should address this. If it does not work out of the box for you, try the new command line options -l, -ll and -lll. Please reopen this issue if you see any problems.

php-coder commented 8 years ago

When I'm trying new version it works without any options. I don't know why...

Thank you!

svenkreiss commented 8 years ago

The default in the new version is not to have an -Xss option when calling Java. Like in your diff a few days ago ;) Thanks!