Skip to content

Change use of NO_DYNAMIC_EXECUTION in embind to DYNAMIC_EXECUTION. #7653

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

Merged
merged 1 commit into from
Dec 13, 2018

Conversation

wffurr
Copy link
Contributor

@wffurr wffurr commented Dec 12, 2018

Adds a validation step to the nodejs command when running the tests with DYNAMIC_EXECUTION=0 to ensure the generated script has no eval. This required adding the ability to specify args to the nodejs command to jsrun.py.

The existing tests didn't catch this bug because they were also affected. The tests check for Module['NO_DYNAMIC_EXECUTION'] which was set by embind.js for the test harness when the NO_DYNAMIC_EXECUTION=1 flag was set.

@wffurr wffurr force-pushed the embind-dynamic-execution branch 2 times, most recently from d7f762e to c183a9a Compare December 12, 2018 20:26
@@ -2399,6 +2399,10 @@ def test_embind(self):
if fail:
self.assertNotEqual(proc.returncode, 0)
else:
if 'DYNAMIC_EXECUTION=0' in args:
output = run_js(self.in_dir('a.out.js'), stdout=PIPE, stderr=PIPE, assert_returncode=0, engine=NODE_JS,
shell_args=['--disallow-code-generation-from-strings'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this test fails on CI, but it passes for me locally. Perhaps this flag is just present in some versions of node.js?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be safer to just scan the output for eval( and new Function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, running locally with Node 8.9.1 (the version used by CircleCI) produces:

/usr/local/google/home/wfurr/Projects/node-v8.9.1-linux-x64/bin/node: bad option: --disallow-code-generation-from-strings

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to string check output per your suggestion. It has to be "new Function(" because "new Function" appears in an error message: https://github.com/kripken/emscripten/blob/incoming/src/embind/embind.js#L852

@wffurr wffurr force-pushed the embind-dynamic-execution branch 2 times, most recently from 2b009e4 to 977e817 Compare December 12, 2018 22:26
Adds a check for uses of 'new Function(' and 'eval(' to test_embind with
DYNAMIC_EXECUTION=0.
@wffurr wffurr force-pushed the embind-dynamic-execution branch from 977e817 to 0feb61b Compare December 12, 2018 22:35
@kripken
Copy link
Member

kripken commented Dec 13, 2018

Great, thanks @wffurr!

btw @sbc100 , other.test_binaryen_methods failed here too, looks like it may be a new intermittent failure as we saw before, although I can't imagine how that could be...

@kripken kripken merged commit edfbab3 into emscripten-core:incoming Dec 13, 2018
@wffurr wffurr deleted the embind-dynamic-execution branch December 13, 2018 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants