Uploaded image for project: 'ClojureScript'
  1. CLJS-2429

Self-host: Printing defrecord form AST memory

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Declined
    • Affects versions: 1.9.908
    • Fix versions: None

      Description

      If printing the AST associated with analyzing a defrecord form with the cljs.js API, memory use is excessive, with things ultimately failing.

      Minimal repro:

      $ java -jar cljs.jar -m cljs.repl.node
      ClojureScript Node.js REPL server listening on 58683
      To quit, type: :cljs/quit
      cljs.user=> (require 'cljs.js)
      nil
      cljs.user=> (def ast (cljs.js/analyze-str (cljs.js/empty-state) "(defrecord Foo [])" nil {:eval cljs.js/js-eval :context :expr} identity))
      #'cljs.user/ast
      cljs.user=> ast
      
      <--- Last few GCs --->
      
      [94684:0x104800000]   108358 ms: Mark-sweep 1402.6 (1459.8) -> 1402.6 (1432.3) MB, 1534.5 / 0.0 ms  (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 1535 ms) last resort
      [94684:0x104800000]   110009 ms: Mark-sweep 1402.6 (1432.3) -> 1402.6 (1432.3) MB, 1651.0 / 0.0 ms  last resort
      
      
      <--- JS stacktrace --->
      
      ==== JS stack trace =========================================
      
      Security context: 0x2babe789cca1 <JSObject>
          1: pr_writer_impl(aka cljs$core$pr_writer_impl) [/Users/mfikes/Downloads/out/.cljs_node_repl/cljs/core.js:~31695] [pc=0x32b9750e856e](this=0x16be3f03b2b1 <Object map = 0x376490efaee9>,obj=1,writer=0x25fbdb95a329 <JSObject>,opts=0x25fbdb95a2e1 <JSObject>)
          2: cljs$core$pr_writer [/Users/mfikes/Downloads/out/.cljs_node_repl/cljs/core.js:~31824] [pc=0x32b9750e4a27](this=0x7540a2892a9 <JSGlob...
      
      FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
       1: node::Abort() [/usr/local/bin/node]
       2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [/usr/local/bin/node]
       3: v8::Utils::ReportOOMFailure(char const*, bool) [/usr/local/bin/node]
       4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/usr/local/bin/node]
       5: v8::internal::Factory::NewFixedArray(int, v8::internal::PretenureFlag) [/usr/local/bin/node]
       6: v8::internal::LoadIC::LoadFullChain(v8::internal::Handle<v8::internal::Map>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Name>, v8::internal::Handle<v8::internal::Smi>) [/usr/local/bin/node]
       7: v8::internal::LoadIC::UpdateCaches(v8::internal::LookupIterator*) [/usr/local/bin/node]
       8: v8::internal::LoadIC::Load(v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Name>) [/usr/local/bin/node]
       9: v8::internal::Runtime_LoadIC_Miss(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
      10: 0x32b974f840dd
      java.lang.IllegalArgumentException: Value out of range for char: -1
      	at clojure.lang.RT.charCast(RT.java:1052)
      	at cljs.repl.node$read_response.invokeStatic(node.clj:49)
      	at cljs.repl.node$node_eval.invokeStatic(node.clj:55)
      	at cljs.repl.node.NodeEnv._evaluate(node.clj:199)
      	at cljs.repl$evaluate_form.invokeStatic(repl.cljc:518)
      	at cljs.repl$eval_cljs.invokeStatic(repl.cljc:631)
      	at cljs.repl$eval_cljs.invoke(repl.cljc:618)
      	at cljs.repl$repl_STAR_$read_eval_print__6323.invoke(repl.cljc:880)
      	at cljs.repl$repl_STAR_$fn__6331$fn__6340.invoke(repl.cljc:925)
      	at cljs.repl$repl_STAR_$fn__6331.invoke(repl.cljc:924)
      	at cljs.compiler$with_core_cljs.invokeStatic(compiler.cljc:1271)
      	at cljs.repl$repl_STAR_.invokeStatic(repl.cljc:882)
      	at cljs.repl$repl.invokeStatic(repl.cljc:1004)
      	at cljs.repl$repl.doInvoke(repl.cljc:936)
      	at clojure.lang.RestFn.invoke(RestFn.java:410)
      	at cljs.repl.node$_main.invokeStatic(node.clj:234)
      	at cljs.repl.node$_main.invoke(node.clj:233)
      	at clojure.lang.Var.invoke(Var.java:375)
      	at clojure.lang.AFn.applyToHelper(AFn.java:152)
      	at clojure.lang.Var.applyTo(Var.java:700)
      	at clojure.core$apply.invokeStatic(core.clj:646)
      	at clojure.main$main_opt.invokeStatic(main.clj:314)
      	at clojure.main$main_opt.invoke(main.clj:310)
      	at clojure.main$main.invokeStatic(main.clj:421)
      	at clojure.main$main.doInvoke(main.clj:384)
      	at clojure.lang.RestFn.invoke(RestFn.java:421)
      	at clojure.lang.Var.invoke(Var.java:383)
      	at clojure.lang.AFn.applyToHelper(AFn.java:156)
      	at clojure.lang.Var.applyTo(Var.java:700)
      	at clojure.main.main(main.java:37)
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mfikes Mike Fikes
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: