Skip to content
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

repl: Mitigate vm #548 function redefinition issue #7624

Closed
wants to merge 4 commits into from

Conversation

princejwesley
Copy link
Contributor

Checklist
  • make -j4 test (UNIX), or vcbuild test nosign (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

repl

Description of change

Transformed function XXX(...) to var XXX = function XXX(...) in order to mitigate vm #548 function redefinition issue

Before
node 🙈  git:(master) ./node
> process.version
'v7.0.0-pre'
> function name() { return "node"; };
undefined
> name()
'node'
> function name() { return "nodejs"; };
undefined
> name()
'node'  // should be 'nodejs'
>
After
node 🙈  git:(upstream  repl-tmp-548) ./node
> function name() { return "node"; };
undefined
> name()
'node'
> function name() { return "nodejs"; };
undefined
> name()
'nodejs'
>

```js
node 🙈 ₹ git:(upstream ⚡ repl-tmp-548) ./node
> function name() { return "node"; };
undefined
> name()
'node'
> function name() { return "nodejs"; };
undefined
> name()
'nodejs'
>
```
@nodejs-github-bot nodejs-github-bot added the repl Issues and PRs related to the REPL subsystem. label Jul 8, 2016
@@ -328,6 +328,11 @@ function error_test() {
// or block comment. https://github.com/nodejs/node/issues/3611
{ client: client_unix, send: 'a = 3.5e',
expect: /^SyntaxError: Invalid or unexpected token/ },
// Mitigate #548 issue
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I'd prefer this be the full URL to the issue rather than just the issue number. (Some issues scattered throughout the code are in nodejs/node-archive (formerly joyent/node, I believe) rather than nodejs/node and using the full URL eliminates guesswork. (Not the comment 3 lines above contains a full issue URL.)

@addaleax
Copy link
Member

addaleax commented Jul 9, 2016

LGTM

Btw, there’s one edge case with unexpected results that will enabled by this change:

> function a() { return 42; } ()
undefined
> a
42

I think it’s okay to accept that as a side effect, though.

CI: https://ci.nodejs.org/job/node-test-commit/4035/

@Trott
Copy link
Member

Trott commented Jul 10, 2016

Maybe add the edge case identified by @addaleax as a known-issues test?


const expected = '1\n[Function a]\n';
const got = r.output.accumulator.join('');
assert.equal(got, expected);
Copy link
Contributor

Choose a reason for hiding this comment

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

Use strict version

@thefourtheye
Copy link
Contributor

Change LGTM, pending CI. We should accept that this will change multiline strings and comments as well.

@princejwesley
Copy link
Contributor Author

princejwesley commented Jul 10, 2016

... We should accept that this will change multiline strings and comments as well.

@thefourtheye I am not quite sure what you meant.

@thefourtheye
Copy link
Contributor

thefourtheye commented Jul 11, 2016

This will replace the definitions even if they are defined within comments or mutiline strings, right?

Edit: nvm. This PR doesn't concern Strings and comments. LGTM stays.

@lance
Copy link
Member

lance commented Jul 15, 2016

LGTM
New CI: https://ci.nodejs.org/job/node-test-pull-request/3302/
Flakey unrelated failure

@lance
Copy link
Member

lance commented Jul 15, 2016

Landed in bb9eabe

@lance lance closed this Jul 15, 2016
addaleax referenced this pull request Jul 17, 2016
```js
node 🙈 ₹ git:(upstream ⚡ repl-tmp-548) ./node
> function name() { return "node"; };
undefined
> name()
'node'
> function name() { return "nodejs"; };
undefined
> name()
'nodejs'
>
```

Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Lance Ball <lball@redhat.com>
@evanlucas
Copy link
Contributor

This isn't landing cleanly on v6.x Mind sending a backport PR to v6.x? Thanks!

@princejwesley
Copy link
Contributor Author

@evanlucas branch name?

@lance
Copy link
Member

lance commented Jul 19, 2016

@princejwesley v6.x

fhinkel added a commit to v8/node that referenced this pull request Sep 18, 2016
deps: update V8 to 6a72f3

Fixes nodejs#548
Makes nodejs#7624 unnecessary.
aqrln added a commit to aqrln/node that referenced this pull request Mar 9, 2017
`test/known_issues/test-repl-function-redefinition-edge-case.js` had
been introduced as a part of nodejs#7624
but the meat of the test became fixed in
007386e. Despite that, the test
continued to fail since it was broken itself: there was a missing colon
in the expected output.

This commit adds the missing colon and moves the test from
`test/known_issues` to `test/parallel`.
jasnell pushed a commit that referenced this pull request Mar 15, 2017
`test/known_issues/test-repl-function-redefinition-edge-case.js` had
been introduced as a part of #7624
but the meat of the test became fixed in
007386e. Despite that, the test
continued to fail since it was broken itself: there was a missing colon
in the expected output.

This commit adds the missing colon and moves the test from
`test/known_issues` to `test/parallel`.

PR-URL: #11772
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
italoacasas pushed a commit to italoacasas/node that referenced this pull request Mar 20, 2017
`test/known_issues/test-repl-function-redefinition-edge-case.js` had
been introduced as a part of nodejs#7624
but the meat of the test became fixed in
007386e. Despite that, the test
continued to fail since it was broken itself: there was a missing colon
in the expected output.

This commit adds the missing colon and moves the test from
`test/known_issues` to `test/parallel`.

PR-URL: nodejs#11772
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
jungx098 pushed a commit to jungx098/node that referenced this pull request Mar 21, 2017
`test/known_issues/test-repl-function-redefinition-edge-case.js` had
been introduced as a part of nodejs#7624
but the meat of the test became fixed in
007386e. Despite that, the test
continued to fail since it was broken itself: there was a missing colon
in the expected output.

This commit adds the missing colon and moves the test from
`test/known_issues` to `test/parallel`.

PR-URL: nodejs#11772
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants