Closed MSardelich closed 10 years ago
If possible, can you give a smaller test case? It seems like the issue comes from trying to serialize an array.
Unfortunately, it crashes with this specific string, maybe many others that show the same property. Point is that I don't know exactly what string characteristics makes HHVM crashes.
Thus, it is difficult to provide a smaller case test. If you look at the query_string url, in the beginning of issue, it doesn't pass any array. BTW, I saw a recent fix (String to Variant). I think you are referring to this. As I said, my educated guess is that it is related to encoding. If you look at the text there exists lots of above 128 chars which I pass using UFT-8.
The best way to replicate the problem is to install wikimedia software (one of the frameworks validated by HHVM) and call the api.php code passing the query_string described at the beginning of the issue, with the text provided at the end. The query request can be coded in any language.
IMPORTANT: Please, use POST method, don't try to call api.php using GET method. Because of fastcgi protocol
specification it only handles maximum 64K (0xffff) request head (layer 3), and GET method insert it within the head. Thus, GET does not work with queries larger than 64K in fastcgi protocol
.
I hope you understand my point and is able to reproduce the issue.
@LiraNuna I have one important piece of information to help you find the incompatibility between php-fpm
and hhvm
when using mediawiki framework
. The HHVM
crash,
Apparently, the crash is totally dependent on the POST size. (Probably, it is a stack buffer overflow)
I wrote a simple Python script which sends a POST to api.php
in Mediawiki Framework
.
Please, run it from your side. It is the easiest way to reproduce the error with a smaller test case.
In addition, please, read carefully the code comments.
in any manner, you can generate your own 'artificial' large POST request in any language. Unfortunately, I don't do PHP, so I wrote in Python.
HERE GOES THE SCRIPT:
With this value of N_TIMES
HHVM crashes.
# I want to generate a large POST message in order to reproduce
# the fact that HHVM crashes when calling api.php script in Wikimedia framework.
#
# The same problem does NOT occur when using php-fpm + fastcgi.
#
# IMPORTANT:
# 1) Configure your webserver to accept large POST size.
# In Apache, add it to your http.conf file: LimitRequestBody 10024000
# 2) Install Python 'requests' package.
#
# The script will not finish because HHVM will crash with SEGFAULT
# and webserver will return 500 status code.
#
# My educated guess is that the issue is a stack buffer overflow, since the crash
# does not depends on the content of POST.
#
import requests
N_TIMES = 100000 # number of times I want to repeat the string below.
text = '[[Help:Template|template]] ' * N_TIMES # repeat 'text' N_TIMES. 'Artificially' generate a large request.
url = 'http://localhost/mediawiki-1.22.6/api.php' # use the version number of your mediawiki installation
params = {
'action': 'parse', # returns the rendered html (in our case [[..]] wiki markup renders to a html link.
'text': text, # our large text
'format': 'xml',
'disablepp': 1,
}
print 'Sending POST request ...'
r = requests.post(url, data=params)
print 'Request returned (%s) status code.' % r.status_code
r.raise_for_status()
print 'Done.'
print 'Total request size: %s' % len(text)
@LiraNuna Since I added the python script above as a new piece of information, could you please change the current status needs more info
?
@LiraNuna any progress regarding this issue?
Not yet, we're working on other stuff. Feel free to send a PR if you get to it before we do.
@LiraNuna thanks for your prompt feedback...I am investigating here...
I tried reproducing this on our HHVM dev box, which has access to the actual English Wikipedia for template expansions etc. I used:
mwscript eval.php --wiki=enwiki
> $text = file_get_contents('greek-place-names.txt');
> $out = $wgParser->parse($text, Title::newMainPage(), new ParserOptions);
There was no crash. There were a lot of OOM errors from LuaSandbox (which limits memory to 50MB), so I tried it with LuaStandalone, then there were no errors and the output looked correct.
@atdt tried running the supplied python script and also could not reproduce the crash.
It is possible this is a fixed bug. I see it was observed on HHVM 3.0.1. @MSardelich, can you reproduce it with a nightly build?
@tstarling thanks for your efforts to reproduce what I see as a bug from my side. Could you please refer to the bug observed on HHVM 3.0.1? (any link, open issue, ...) It could help me... I am involved in different projects right now, but I will try to reproduce with a nightly build.and will let you know. tks...
(@MSardelich, I think @tstarling was referring to the fact that the bug was observed by you on 3.0.1, as you indicate in your initial report.)
I am using mediawiki framework to parse wikitexts.
If wikimedia software is installed, the url which calls the Parse Class is:
where
XXX
is the text that I am trying to parse (wikitext to html).Depending on the text value HHVM crashes.
The same doesn't happen when using php-fpm + FastCgi.
Since the crash depends on the text value, I will attach the exact text at the end of this issue. Thus, anyone can easily reproduce the error.
HHVM crashes receiving SIGSEGV, below the
gdb backtrace
:My educated guess is that the bug is related to encoding in
LvalStrPacked
, the first call in the stack.Just in case, I am using standard UFT-8 for encoding any external call.
MY CONFIGURATION
**The text which reproduces the error (a text which comes with the standard wikimedia dump file):***