-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QuickJS modules. #779
QuickJS modules. #779
Conversation
be0c3b0
to
fbbddf9
Compare
f922771
to
e62e638
Compare
Issues found with latest quickjs and nginx with memory sanitizer. #!/usr/bin/perl ############################################################################### use warnings; use Test::More; BEGIN { use FindBin; chdir($FindBin::Bin); } use lib 'lib'; ############################################################################### select STDERR; $| = 1; my $t = Test::Nginx->new()->has(qw/http rewrite/) %%TEST_GLOBALS%% daemon off; events { http {
} EOF $t->write_file('test.js', <<EOF);
EOF $t->try_run('no njs available')->plan(1); ############################################################################### like(http_post('/request_body_cache'), $t->stop(); ############################################################################### sub http_post { <------>my $p = "POST $url HTTP/1.0" . CRLF . <------>return http($p, %extra); ############################################################################### Direct leak: ================================================================= Direct leak of 25 byte(s) in 1 object(s) allocated from: signal 6 is from assertion: |
efbf18f
to
5193dd0
Compare
looks like we have few issues: |
da19272
to
ab19fef
Compare
5af3730
to
ceec08b
Compare
While it is useful for debugging what objects are leaking at the end this flag hides QuickJS JSString leaks from Address Sanitizer.
No functional changes.
ceec08b
to
27f70ec
Compare
There are some build/test breakages on select buildbot platforms with this PR, please hold off merging as of |
45bc78a
to
c4e8532
Compare
"js_engine" directive is introduced which sets JavaScript engine. When the module is built with QuickJS library "js_engine qjs;" sets QuickJS engine for the current block. By default njs engine is used. For example, nginx.conf: location /a { js_engine qjs; # will be handled by QuickJS js_content main.handler; } location /b { # will be handled by njs js_content main.handler; } QuickJS engine implements drop-in replacement for nginx/njs objects with the following exceptions: * nginx module API to be added later: ngx.fetch(), ngx.shared.dict. * Built-in modules to be added later: fs, crypto, WebCrypto, xml. * NJS specific API: njs.dump(), njs.on(), console.dump(). * js_preload_object directive.
c4e8532
to
a833fa5
Compare
Two main patches:
Modules: introduced engine API. - adapts the modules code to allow multiple JS engines.
Modules: introduced QuickJS engine.
"js_engine" directive is introduced which sets JavaScript engine.
When the module is built with QuickJS library "js_engine qjs;" sets
QuickJS engine for the current block. By default njs engine is used.
For example,
nginx.conf:
QuickJS engine implements drop-in replacement for nginx/njs objects
with the following exceptions:
Use
TEST_NGINX_GLOBALS_HTTP='js_engine qjs;' TEST_NGINX_GLOBALS_STREAM='js_engine qjs;'
when running njs tests to test QuickJS module.For example:
to run tests with njs engine:
TEST_NGINX_BINARY=/path/to/nginx/binary prove -I /path/to/nginx-tests/lib/ nginx/t/
to run tests with QuickJS engine:
TEST_NGINX_GLOBALS_HTTP='js_engine qjs;' TEST_NGINX_GLOBALS_STREAM='js_engine qjs;' TEST_NGINX_BINARY=/path/to/nginx/binary prove -I /path/to/nginx-tests/lib/ nginx/t/