google / closure-compiler

A JavaScript checker and optimizer.
https://developers.google.com/closure/compiler/
Apache License 2.0
7.41k stars 1.15k forks source link

ICE: Cannot read field "references" because "referenceInfo" is null #4200

Open RuifengFu opened 1 week ago

RuifengFu commented 1 week ago

While fuzzing the Closure Compiler using JQF, I encountered an internal compiler error. The compiler throws a RuntimeException with the message INTERNAL COMPILER ERROR. Below is the relevant part of the stack trace and the input code that triggered the error.

version: v20240317

Stack Trace:

java.lang.RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.

Cannot read field "references" because "referenceInfo" is null
  Node(FOR): input:1:173
((b_0)[({q_1: (q_1), u_2: (b_0), i_3: ({q_1: (({u_2: (i_3), f_4: (q_1), y_5: (((new ((true) ? (m_6) : (null))()).w_7)[({w_7: ((q_8)[(function(m_9, m_6, n_10, p_11){ var i_3;for((p_12);;(n_10)){ while ((undefined)){ throw (c_13);try {  }catch (p_11) { ;break;;throw (i_3) };return;(this);break;switch((y_5)) {case ("$Z8f"): { switch((true)) {case (undefined): { ;var b_0;return } case (b_0): { var q_1;continue;var v_14;throw (undefined) } case (656): { var f_15;;(383) }};var r_16;("????");(b_0);while ((undefined)){ continue;(h_17);return (229);break };while ((null)){ (c_18);;break;continue;return (null);continue } }};if ((true)) { var h_19;while ((b_0)){ (null) };while (("`")){ break;var u_20;continue;return (this);throw (y_21);return };throw (null);throw (undefined);switch((r_22)) {case (w_7): { (h_23);throw (391);return (l_24);;var h_17 } case (true): { continue; }} }{ break;{ continue };break;;try { continue;;continue;var o_25;break;(e_26) }catch (j_27) {  } } };function b_0(p_28, r_29){ switch((w_7)) {} };function h_30(j_31){  };{ break;continue } } })]), c_32: ((y_5, c_13, f_33, j_34, c_18) => (undefined)), q_1: (~ (y_21)), m_35: (y_21), c_36: ({})})])}).u_37), p_38: (b_0)})})])
  Parent(BLOCK): input:1:163
((b_0)[({q_1: (q_1), u_2: (b_0), i_3: ({q_1: (({u_2: (i_3), f_4: (q_1), y_5: (((new ((true) ? (m_6) : (null))()).w_7)[({w_7: ((q_8)[(function(m_9, m_6, n_10, p_11){ var i_3;for((p_12);;(n_10)){ while ((undefined)){ throw (c_13);try {  }catch (p_11) { ;break;;throw (i_3) };return;(this);break;switch((y_5)) {case ("$Z8f"): { switch((true)) {case (undefined): { ;var b_0;return } case (b_0): { var q_1;continue;var v_14;throw (undefined) } case (656): { var f_15;;(383) }};var r_16;("????");(b_0);while ((undefined)){ continue;(h_17);return (229);break };while ((null)){ (c_18);;break;continue;return (null);continue } }};if ((true)) { var h_19;while ((b_0)){ (null) };while (("`")){ break;var u_20;continue;return (this);throw (y_21);return };throw (null);throw (undefined);switch((r_22)) {case (w_7): { (h_23);throw (391);return (l_24);;var h_17 } case (true): { continue; }} }{ break;{ continue };break;;try { continue;;continue;var o_25;break;(e_26) }catch (j_27) {  } } };function b_0(p_28, r_29){ switch((w_7)) {} };function h_30(j_31){  };{ break;continue } } })]), c_32: ((y_5, c_13, f_33, j_34, c_18) => (undefined)), q_1: (~ (y_21)), m_35: (y_21), c_36: ({})})])}).u_37), p_38: (b_0)})})])

    at com.google.javascript.jscomp.Compiler.throwInternalError(Compiler.java:3282)
    at com.google.javascript.jscomp.NodeTraversal.throwUnexpectedException(NodeTraversal.java:516)
    at com.google.javascript.jscomp.NodeTraversal.traverseRoots(NodeTraversal.java:560)
    at com.google.javascript.jscomp.NodeTraversal$Builder.traverseRoots(NodeTraversal.java:480)
    at com.google.javascript.jscomp.ReferenceCollector.process(ReferenceCollector.java:103)
    at com.google.javascript.jscomp.InlineObjectLiterals.process(InlineObjectLiterals.java:63)
    at com.google.javascript.jscomp.PhaseOptimizer$NamedPass.process(PhaseOptimizer.java:240)
    at com.google.javascript.jscomp.PhaseOptimizer$Loop.process(PhaseOptimizer.java:378)
    at com.google.javascript.jscomp.PhaseOptimizer.process(PhaseOptimizer.java:179)
    at com.google.javascript.jscomp.Compiler.performTranspilationAndOptimizations(Compiler.java:2968)
    at com.google.javascript.jscomp.Compiler.lambda$stage2Passes$7(Compiler.java:1025)
    at com.google.javascript.jscomp.CompilerExecutor.runInCompilerThread(CompilerExecutor.java:126)
    at com.google.javascript.jscomp.Compiler.runInCompilerThread(Compiler.java:1073)
    at com.google.javascript.jscomp.Compiler.stage2Passes(Compiler.java:1022)
    at com.google.javascript.jscomp.Compiler.compile(Compiler.java:908)
    at com.google.javascript.jscomp.Compiler.compile(Compiler.java:878)

Input Code:

((b_0)[({q_1: (q_1), u_2: (b_0), i_3: ({q_1: (({u_2: (i_3), f_4: (q_1), y_5: (((new ((true) ? (m_6) : (null))()).w_7)[({w_7: ((q_8)[(function(m_9, m_6, n_10, p_11){ var i_3;for((p_12);;(n_10)){ while ((undefined)){ throw (c_13);try {  }catch (p_11) { ;break;;throw (i_3) };return;(this);break;switch((y_5)) {case ("$Z8f"): { switch((true)) {case (undefined): { ;var b_0;return } case (b_0): { var q_1;continue;var v_14;throw (undefined) } case (656): { var f_15;;(383) }};var r_16;("????");(b_0);while ((undefined)){ continue;(h_17);return (229);break };while ((null)){ (c_18);;break;continue;return (null);continue } }};if ((true)) { var h_19;while ((b_0)){ (null) };while (("`")){ break;var u_20;continue;return (this);throw (y_21);return };throw (null);throw (undefined);switch((r_22)) {case (w_7): { (h_23);throw (391);return (l_24);;var h_17 } case (true): { continue; }} }{ break;{ continue };break;;try { continue;;continue;var o_25;break;(e_26) }catch (j_27) {  } } };function b_0(p_28, r_29){ switch((w_7)) {} };function h_30(j_31){  };{ break;continue } } })]), c_32: ((y_5, c_13, f_33, j_34, c_18) => (undefined)), q_1: (~ (y_21)), m_35: (y_21), c_36: ({})})])}).u_37), p_38: (b_0)})})])