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

INTERNAL COMPILER ERROR when module.exports refers to vars using combined var statement #2450

Closed
Deraen opened this issue Apr 21, 2017 · 7 comments
Assignees

Comments

@Deraen
Copy link
Contributor

Deraen commented Apr 21, 2017

INTERNAL COMPILER ERROR when module.exports refers to vars using combined var statement

Problem was noticed by @atroche when trying to use https://github.com/joyent/node-bcrypt-pbkdf with ClojureScript.

Here is a minimal case which defines two vars using combined var statement and exposes those in module.exports. If both vars have their own var statements no error occurs.

foozz/bar.js

var BCRYPT_BLOCKS = 8,
    BCRYPT_HASHSIZE = 32;

module.exports = {
      BLOCKS: BCRYPT_BLOCKS,
      HASHSIZE: BCRYPT_HASHSIZE,
};
❯ java -jar closure-compiler-v20170409.jar --js foozz/bar.js --process_common_js_modules
java.lang.RuntimeException: java.lang.RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.

null
  Node(NAME BCRYPT_HASHSIZE): foozz/bar.js:2:4
    BCRYPT_HASHSIZE = 32;
  Parent(VAR): foozz/bar.js:1:0
var BCRYPT_BLOCKS = 8,

	at com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread(CompilerExecutor.java:126)
	at com.google.javascript.jscomp.Compiler.runInCompilerThread(Compiler.java:753)
	at com.google.javascript.jscomp.Compiler.compile(Compiler.java:723)
	at com.google.javascript.jscomp.Compiler.compile(Compiler.java:693)
	at com.google.javascript.jscomp.AbstractCommandLineRunner.doRun(AbstractCommandLineRunner.java:1080)
	at com.google.javascript.jscomp.AbstractCommandLineRunner.run(AbstractCommandLineRunner.java:492)
	at com.google.javascript.jscomp.CommandLineRunner.main(CommandLineRunner.java:1898)
Caused by: java.lang.RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.

null
  Node(NAME BCRYPT_HASHSIZE): foozz/bar.js:2:4
    BCRYPT_HASHSIZE = 32;
  Parent(VAR): foozz/bar.js:1:0
var BCRYPT_BLOCKS = 8,

	at com.google.javascript.rhino.Node.replaceWith(Node.java:867)
	at com.google.javascript.jscomp.ProcessCommonJSModules$RewriteModule.updateNameReference(ProcessCommonJSModules.java:1063)
	at com.google.javascript.jscomp.ProcessCommonJSModules$RewriteModule.maybeUpdateName(ProcessCommonJSModules.java:942)
	at com.google.javascript.jscomp.ProcessCommonJSModules$RewriteModule.visit(ProcessCommonJSModules.java:704)
	at com.google.javascript.jscomp.NodeTraversal.traverseBranch(NodeTraversal.java:639)
	at com.google.javascript.jscomp.NodeTraversal.traverseChildren(NodeTraversal.java:711)
	at com.google.javascript.jscomp.NodeTraversal.traverseBranch(NodeTraversal.java:635)
	at com.google.javascript.jscomp.NodeTraversal.traverseChildren(NodeTraversal.java:711)
	at com.google.javascript.jscomp.NodeTraversal.traverseBranch(NodeTraversal.java:635)
	at com.google.javascript.jscomp.NodeTraversal.traverse(NodeTraversal.java:311)
	at com.google.javascript.jscomp.NodeTraversal.traverseEs6(NodeTraversal.java:582)
	at com.google.javascript.jscomp.ProcessCommonJSModules.process(ProcessCommonJSModules.java:128)
	at com.google.javascript.jscomp.Compiler.processAMDAndCommonJSModules(Compiler.java:1856)
	at com.google.javascript.jscomp.Compiler.parseInputs(Compiler.java:1564)
	at com.google.javascript.jscomp.Compiler.parse(Compiler.java:810)
	at com.google.javascript.jscomp.Compiler.compileInternal(Compiler.java:763)
	at com.google.javascript.jscomp.Compiler.access$000(Compiler.java:87)
	at com.google.javascript.jscomp.Compiler$2.call(Compiler.java:726)
	at com.google.javascript.jscomp.Compiler$2.call(Compiler.java:723)
	at com.google.javascript.jscomp.CompilerExecutor$2.call(CompilerExecutor.java:91)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
	... 24 more
@kylecordes
Copy link

Related to this and other items (and I'm asking here, to not add the noise of another item for a possibly useless idea...), how about some kind of "fuzz testing", something to emit random valid JS programs as part of the Closure test suite? It is frustrating to see constructs discovered once at a time by Closure users that result in an INTERNAL COMPILER ERROR, appealing to see them discovered (and fixed?) en masse instead.

(Ulterior motive... I'm hoping to see Closure in widespread use in a couple of years on sprawling Angular applications with lots of varied library code mixed in... which will likely span much of the space of possible JS constructs.)

@MatrixFrog
Copy link
Contributor

We had a fuzzer a few years back. It was deleted in c5d1ade but we might resurrect it someday.

@kylecordes
Copy link

@MatrixFrog Thank you, I will watch the commits/PRs to see if it comes back someday.

@ChadKillingsworth
Copy link
Collaborator

CommonJS modules are not used widely within Google and thus aren't as battle hardened as other passes. That and I rewrote the pass from scratch last year.

kommen added a commit to nextjournal/closure-compiler that referenced this issue May 29, 2017
@kommen
Copy link
Contributor

kommen commented May 29, 2017

A ran into the same issue. See #2507

I've added a test case which reproduces the problem here: nextjournal@2b75244

@kommen
Copy link
Contributor

kommen commented May 29, 2017

I submitted a PR with a fix for the problem here: #2509

Looking forward to your feedback.

@Deraen
Copy link
Contributor Author

Deraen commented Jul 31, 2017

I think this can be closed now that 8fc8229 is merged.

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 a pull request may close this issue.

5 participants