mfikes / ambly

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

Hang if connect to stale bonjour advertisement #55

Closed mfikes closed 9 years ago

mfikes commented 9 years ago

I was testing Ambly on my laptop, but evidently had Shrimp running on my desktop (from yesterday). So, I attempted to connect to it and the Ambly REPL hung indefinitely. I did a kill -3 to capture where it was hung up. Here is the transcript:

cgouff-XPS360:ClojureScript mfikes$ script/jscrepljs 
To quit, type: :cljs/quit

[1] Shrimp on iPhone Simulator (Mike-Fikess-MacBook-Pro)
[2] Shrimp on iPhone Simulator (orion-fikesfarm-com)

[R] Refresh

Choice: 2

Connecting to Shrimp on iPhone Simulator (orion-fikesfarm-com) ...

2015-03-03 19:33:01
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.25-b02 mixed mode):

"Thread-6" #19 prio=5 os_prio=31 tid=0x00007fef75442800 nid=0x5e03 runnable [0x000000011f37d000]
   java.lang.Thread.State: RUNNABLE
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:150)
    at java.net.SocketInputStream.read(SocketInputStream.java:121)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:284)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
    - locked <0x000000079cfad050> (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 <0x000000079cfaf088> (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 <0x000000079cfaf088> (a java.io.InputStreamReader)
    at ambly.repl.jsc$read_messages.invoke(jsc.clj:116)
    at ambly.repl.jsc$start_reading_messages$fn__3868.invoke(jsc.clj:127)
    at clojure.lang.AFn.run(AFn.java:22)
    at java.lang.Thread.run(Thread.java:745)

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

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

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

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

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

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

"Finalizer" #3 daemon prio=8 os_prio=31 tid=0x00007fef7584f800 nid=0x3503 in Object.wait() [0x000000011ba22000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x0000000740219588> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:142)
    - locked <0x0000000740219588> (a java.lang.ref.ReferenceQueue$Lock)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:158)
    at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)

"Reference Handler" #2 daemon prio=10 os_prio=31 tid=0x00007fef75013800 nid=0x3303 in Object.wait() [0x000000011b91f000]
   java.lang.Thread.State: WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    - waiting on <0x000000074014a1c8> (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 <0x000000074014a1c8> (a java.lang.ref.Reference$Lock)

"main" #1 prio=5 os_prio=31 tid=0x00007fef75000800 nid=0x1303 waiting on condition [0x00000001029a7000]
   java.lang.Thread.State: WAITING (parking)
    at sun.misc.Unsafe.park(Native Method)
    - parking to wait for  <0x00000007a52d0b48> (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__6363.deref(core.clj:6553)
    at clojure.core$deref.invoke(core.clj:2200)
    at ambly.repl.jsc$jsc_eval.invoke(jsc.clj:165)
    at ambly.repl.jsc.JscEnv._evaluate(jsc.clj:299)
    at cljs.repl$load_namespace.invoke(repl.clj:162)
    at cljs.repl$load_dependencies.invoke(repl.clj:171)
    at cljs.repl$evaluate_form.invoke(repl.clj:373)
    at cljs.repl$repl_STAR_$fn__3805$fn__3806.invoke(repl.clj:659)
    at cljs.repl$repl_STAR_$fn__3805.invoke(repl.clj:655)
    at cljs.compiler$with_core_cljs.invoke(compiler.clj:912)
    at cljs.repl$repl_STAR_.invoke(repl.clj:653)
    at user$eval3933.invoke(form-init1447360522515058497.clj:3)
    at clojure.lang.Compiler.eval(Compiler.java:6703)
    at clojure.lang.Compiler.eval(Compiler.java:6666)
    at clojure.core$eval.invoke(core.clj:2927)
    at clojure.main$eval_opt.invoke(main.clj:288)
    at clojure.main$initialize.invoke(main.clj:307)
    at clojure.main$null_opt.invoke(main.clj:342)
    at clojure.main$main.doInvoke(main.clj:420)
    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)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
    at clojure.lang.Reflector.invokeStaticMethod(Reflector.java:207)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:93)
    at clojure.lang.Reflector.invokeStaticMethod(Reflector.java:207)
    at user$eval5.invoke(form-init1447360522515058497.clj:1)
    at clojure.lang.Compiler.eval(Compiler.java:6703)
    at clojure.lang.Compiler.eval(Compiler.java:6693)
    at clojure.lang.Compiler.load(Compiler.java:7130)
    at clojure.lang.Compiler.loadFile(Compiler.java:7086)
    at clojure.main$load_script.invoke(main.clj:274)
    at clojure.main$init_opt.invoke(main.clj:279)
    at clojure.main$initialize.invoke(main.clj:307)
    at clojure.main$null_opt.invoke(main.clj:342)
    at clojure.main$main.doInvoke(main.clj:420)
    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=0x00007fef7584f000 nid=0x3103 runnable 

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

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

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

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

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

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

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

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

"VM Periodic Task Thread" os_prio=31 tid=0x00007fef75828800 nid=0x5303 waiting on condition 

JNI global references: 91

Heap
 PSYoungGen      total 273408K, used 259638K [0x0000000795580000, 0x00000007a6780000, 0x00000007c0000000)
  eden space 266240K, 97% used [0x0000000795580000,0x00000007a530d9b0,0x00000007a5980000)
  from space 7168K, 0% used [0x00000007a6080000,0x00000007a6080000,0x00000007a6780000)
  to   space 7168K, 0% used [0x00000007a5980000,0x00000007a5980000,0x00000007a6080000)
 ParOldGen       total 58368K, used 7318K [0x0000000740000000, 0x0000000743900000, 0x0000000795580000)
  object space 58368K, 12% used [0x0000000740000000,0x0000000740725a48,0x0000000743900000)
 Metaspace       used 24909K, capacity 31811K, committed 32000K, reserved 1073152K
  class space    used 5778K, capacity 7865K, committed 7936K, reserved 1048576K

The line numbers above correspond to https://github.com/omcljs/ambly/blob/00336aa78794ea89903aa059f9678f9aa24d10ea/Clojure/src/ambly/repl/jsc.clj

mfikes commented 9 years ago

This only happens for me when connecting to a sleeping remote Mac. Sometimes things work and, even if they do, you can come back later to evaluate a simple form like 1 and things can block for a long time. Since this ticket had been originally written, keep-alines have been added, and this can result in errors ultimately being displayed, for example:

java.net.SocketException: Operation timed out
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.read(SocketInputStream.java:150)
    at java.net.SocketInputStream.read(SocketInputStream.java:121)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:284)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
    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)
    at java.io.InputStreamReader.read(InputStreamReader.java:184)
    at java.io.BufferedReader.fill(BufferedReader.java:161)
    at java.io.BufferedReader.read(BufferedReader.java:182)
    at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    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:140)
    at ambly.repl.jsc$start_reading_messages$fn__4257.invoke(jsc.clj:152)
    at clojure.lang.AFn.run(AFn.java:22)
    at java.lang.Thread.run(Thread.java:745)