mfikes / ambly

ClojureScript REPL into embedded JavaScriptCore
http://ambly.fikesfarm.com
Eclipse Public License 1.0
541 stars 21 forks source link

REPL hang after Mac sleep #79

Closed mfikes closed 9 years ago

mfikes commented 9 years ago

Establish a REPL to a simulator and evaluate a few simple forms. Then let the Mac go to sleep. Wake up and evaluate a form. The REPL can hang. (The threads in the simulator show nothing suspicious.)

Here's a thread dump for the REPL after sleeping and trying to evaluate a form:

2015-04-29 00:29:52
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.45-b02 mixed mode):

"Thread-5" #26 prio=5 os_prio=31 tid=0x00007fde9a182000 nid=0x4f07 runnable [0x0000000139dbe000]
   java.lang.Thread.State: RUNNABLE
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
    at java.net.SocketInputStream.read(SocketInputStream.java:170)
    at java.net.SocketInputStream.read(SocketInputStream.java:141)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:284)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
    - locked <0x0000000743763bd8> (a java.io.BufferedInputStream)
    at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
    at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
    - locked <0x0000000743765c10> (a java.io.InputStreamReader)
    at java.io.InputStreamReader.read(InputStreamReader.java:184)
    at java.io.BufferedReader.fill(BufferedReader.java:161)
    at java.io.BufferedReader.read(BufferedReader.java:182)
    - locked <0x0000000743765c10> (a java.io.InputStreamReader)
    at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
    at clojure.lang.Reflector.invokeNoArgInstanceMember(Reflector.java:313)
    at ambly.repl.jsc$read_messages.invoke(jsc.clj:176)
    at ambly.repl.jsc$start_reading_messages$fn__4379.invoke(jsc.clj:188)
    at clojure.lang.AFn.run(AFn.java:22)
    at java.lang.Thread.run(Thread.java:745)

"Service Thread" #17 daemon prio=9 os_prio=31 tid=0x00007fde9a01f000 nid=0x7503 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C1 CompilerThread11" #16 daemon prio=9 os_prio=31 tid=0x00007fde9e830000 nid=0x7303 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C1 CompilerThread10" #15 daemon prio=9 os_prio=31 tid=0x00007fde9c80b000 nid=0x7103 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C1 CompilerThread9" #14 daemon prio=9 os_prio=31 tid=0x00007fde9d000800 nid=0x6f03 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C1 CompilerThread8" #13 daemon prio=9 os_prio=31 tid=0x00007fde9e82f000 nid=0x6d03 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread7" #12 daemon prio=9 os_prio=31 tid=0x00007fde9b811000 nid=0x6b03 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread6" #11 daemon prio=9 os_prio=31 tid=0x00007fde9b810800 nid=0x6903 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread5" #10 daemon prio=9 os_prio=31 tid=0x00007fde9b80f800 nid=0x6703 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread4" #9 daemon prio=9 os_prio=31 tid=0x00007fde9b807000 nid=0x6503 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread3" #8 daemon prio=9 os_prio=31 tid=0x00007fde9e826800 nid=0x6303 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread2" #7 daemon prio=9 os_prio=31 tid=0x00007fde9e825800 nid=0x6103 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" #6 daemon prio=9 os_prio=31 tid=0x00007fde9e818000 nid=0x5f03 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" #5 daemon prio=9 os_prio=31 tid=0x00007fde9e816000 nid=0x5d03 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" #4 daemon prio=9 os_prio=31 tid=0x00007fde9e824000 nid=0x5013 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" #3 daemon prio=8 os_prio=31 tid=0x00007fde9a863000 nid=0x4903 in Object.wait() [0x0000000135724000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x0000000640011320> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
    - locked <0x0000000640011320> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)

"Reference Handler" #2 daemon prio=10 os_prio=31 tid=0x00007fde9a862800 nid=0x4703 in Object.wait() [0x0000000135621000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x0000000640009578> (a java.lang.ref.Reference$Lock)
    at java.lang.Object.wait(Object.java:502)
    at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:157)
    - locked <0x0000000640009578> (a java.lang.ref.Reference$Lock)

"main" #1 prio=5 os_prio=31 tid=0x00007fde9a00d000 nid=0x1303 waiting on condition [0x000000010e74d000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x000000074d726730> (a java.util.concurrent.CountDownLatch$Sync)
    at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:997)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304)
    at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:231)
    at clojure.core$promise$reify__6773.deref(core.clj:6812)
    at clojure.core$deref.invoke(core.clj:2204)
    at ambly.repl.jsc$jsc_eval.invoke(jsc.clj:265)
    at ambly.repl.jsc.JscEnv._evaluate(jsc.clj:460)
    at cljs.repl$evaluate_form.invoke(repl.clj:463)
    at cljs.repl$eval_cljs.invoke(repl.clj:541)
    at cljs.repl$repl_STAR_$read_eval_print__4229.invoke(repl.clj:807)
    at cljs.repl$repl_STAR_$fn__4235$fn__4242.invoke(repl.clj:844)
    at cljs.repl$repl_STAR_$fn__4235.invoke(repl.clj:843)
    at cljs.compiler$with_core_cljs.invoke(compiler.clj:964)
    at cljs.repl$repl_STAR_.invoke(repl.clj:809)
    at cljs.repl$repl.doInvoke(repl.clj:925)
    at clojure.lang.RestFn.invoke(RestFn.java:410)
    at ambly.repl.jsc$_main.invoke(jsc.clj:479)
    at clojure.lang.Var.invoke(Var.java:375)
    at user$eval5.invoke(form-init7232893021789623209.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6792)
    at clojure.lang.Compiler.eval(Compiler.java:6782)
    at clojure.lang.Compiler.load(Compiler.java:7237)
    at clojure.lang.Compiler.loadFile(Compiler.java:7175)
    at clojure.main$load_script.invoke(main.clj:275)
    at clojure.main$init_opt.invoke(main.clj:280)
    at clojure.main$initialize.invoke(main.clj:308)
    at clojure.main$null_opt.invoke(main.clj:343)
    at clojure.main$main.doInvoke(main.clj:421)
    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)

"VM Thread" os_prio=31 tid=0x00007fde9a85f800 nid=0x4503 runnable 

"GC task thread#0 (ParallelGC)" os_prio=31 tid=0x00007fde9a805800 nid=0x2103 runnable 

"GC task thread#1 (ParallelGC)" os_prio=31 tid=0x00007fde9a806800 nid=0x2303 runnable 

"GC task thread#2 (ParallelGC)" os_prio=31 tid=0x00007fde9a807000 nid=0x2503 runnable 

"GC task thread#3 (ParallelGC)" os_prio=31 tid=0x00007fde9b002800 nid=0x2703 runnable 

"GC task thread#4 (ParallelGC)" os_prio=31 tid=0x00007fde9a807800 nid=0x2903 runnable 

"GC task thread#5 (ParallelGC)" os_prio=31 tid=0x00007fde9a016000 nid=0x2b03 runnable 

"GC task thread#6 (ParallelGC)" os_prio=31 tid=0x00007fde9a016800 nid=0x2d03 runnable 

"GC task thread#7 (ParallelGC)" os_prio=31 tid=0x00007fde9a017000 nid=0x2f03 runnable 

"GC task thread#8 (ParallelGC)" os_prio=31 tid=0x00007fde9a018000 nid=0x3103 runnable 

"GC task thread#9 (ParallelGC)" os_prio=31 tid=0x00007fde9a808000 nid=0x3303 runnable 

"GC task thread#10 (ParallelGC)" os_prio=31 tid=0x00007fde9a809000 nid=0x3503 runnable 

"GC task thread#11 (ParallelGC)" os_prio=31 tid=0x00007fde9a809800 nid=0x3703 runnable 

"GC task thread#12 (ParallelGC)" os_prio=31 tid=0x00007fde9a80a000 nid=0x3903 runnable 

"GC task thread#13 (ParallelGC)" os_prio=31 tid=0x00007fde9a80a800 nid=0x3b03 runnable 

"GC task thread#14 (ParallelGC)" os_prio=31 tid=0x00007fde9a80b800 nid=0x3d03 runnable 

"GC task thread#15 (ParallelGC)" os_prio=31 tid=0x00007fde9a80c000 nid=0x3f03 runnable 

"GC task thread#16 (ParallelGC)" os_prio=31 tid=0x00007fde9a80c800 nid=0x4103 runnable 

"GC task thread#17 (ParallelGC)" os_prio=31 tid=0x00007fde9a80d000 nid=0x4303 runnable 

"VM Periodic Task Thread" os_prio=31 tid=0x00007fde9a079000 nid=0x7703 waiting on condition 

JNI global references: 403

Heap
 PSYoungGen      total 322048K, used 235496K [0x0000000740000000, 0x0000000755e80000, 0x00000007c0000000)
  eden space 309248K, 72% used [0x0000000740000000,0x000000074d981288,0x0000000752e00000)
  from space 12800K, 99% used [0x0000000753e80000,0x0000000754af8e98,0x0000000754b00000)
  to   space 16896K, 0% used [0x0000000752e00000,0x0000000752e00000,0x0000000753e80000)
 ParOldGen       total 142848K, used 11577K [0x0000000640000000, 0x0000000648b80000, 0x0000000740000000)
  object space 142848K, 8% used [0x0000000640000000,0x0000000640b4e408,0x0000000648b80000)
 Metaspace       used 27115K, capacity 34988K, committed 35072K, reserved 1075200K
  class space    used 6257K, capacity 8666K, committed 8704K, reserved 1048576K
mfikes commented 9 years ago

This appears to now be fixed for REPLs into the simulator owing to #82.

I want to still check for this in the case where a Mac is connected to an actual device and the Mac sleeps.

mfikes commented 9 years ago

Appears to be fixed.