Skip to content

REPL: thread blocked indefinitely in an MVar operation #870

@shirouto

Description

@shirouto

Description

While running forM_ [0..4096 print] in etlas repl, I got

eta: panic! (the 'impossible' happened)                                                                                                                                                                                                       
  (Eta version 0.8.6b2):                                                                                                                                                                                                                      
        java.lang.RuntimeException: Failed during evalIO of Eta REPL expression                                                                                                                                                               
        at eta.serv.REPLClassLoader.evalIO(REPLClassLoader.java:263)                                                                                                                                                                          
        at eta.serv.Utils.evalIO(Utils.java:42)                                                                                                                                                                                               
        at main.eta.serv.Run$sat$33.applyV(Run.hs:84)                                                                                                                                                                                         
        at eta.runtime.exception.Exception.catch_(Exception.java:132)                                                                                                                                                                         
        at main.eta.serv.Run.run1(Run.hs:181)                                                                                                                                                                                                 
        at main.Lib.$wa(Lib.hs:23)
        at main.Main$sat$1.applyV(Main.hs:36)
        at eta.runtime.exception.Exception.maskUninterruptible(Exception.java:69)
        at main.Main.main6(Main.hs:37)
        at main.Main.main4(Main.hs:34)
        at main.Main.main1(Main.hs:32)
        at main.Main$main1.applyV(Main.hs)
        at eta.runtime.exception.Exception.catch_(Exception.java:132)
        at main.Main.main7(Main.hs)
        at main.Main.DZCmain(Main.hs:25)
        at main.Main$DZCmain.applyV(Main.hs:25)
        at eta.runtime.stg.Closures$EvalLazyIO.enter(Closures.java:125)
        at eta.runtime.stg.Capability.schedule(Capability.java:254)
        at eta.runtime.stg.Capability.scheduleClosure(Capability.java:210)
        at eta.runtime.Runtime.evalLazyIO(Runtime.java:372)
        at eta.runtime.Runtime.main(Runtime.java:365)
        at eta.main.main(Unknown Source)
Caused by: java.lang.RuntimeException: Failed during evalIOInternal of Eta REPL expression
        at eta.serv.REPLClassLoader.evalIOInternal(REPLClassLoader.java:381)
        at eta.serv.REPLClassLoader.evalIO(REPLClassLoader.java:261)
        ... 21 more
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at eta.serv.REPLClassLoader.evalIOInternal(REPLClassLoader.java:379)
        ... 22 more
Caused by: eta.runtime.exception.EtaException: thread blocked indefinitely in an MVar operation
        at eta.runtime.stg.Capability.detectMVarDeadlock(Capability.java:711)
        at eta.runtime.stg.Capability.idleLoop(Capability.java:698)
        at eta.runtime.stg.Capability.blockedLoop(Capability.java:736)
        at eta.runtime.stg.Capability.blockedLoop(Capability.java:732)
        at eta.runtime.concurrent.Concurrent.takeMVar(Concurrent.java:79)
        at base.ghc.io.handle.Internals.$wa2(Internals.hs:164)
        at base.ghc.io.handle.Internals$a3.applyV(Internals.hs:133)
        at eta.runtime.exception.Exception.maskAsyncExceptions(Exception.java:45)
        at base.ghc.io.handle.Internals.$wa4(Internals.hs:131)
        at base.ghc.io.handle.Internals.$wa3(Internals.hs:237)
        at base.ghc.io.handle.Internals.wantWritableHandle1(Internals.hs:227)
        at base.ghc.io.Handle.hFlush1(Handle.hs:305)
        at base.ghc.io.Handle.hFlush(Handle.hs:305)
        at base.ghc.io.Handle$hFlush.apply1V(Handle.hs:305)

This is probably related to a stack overflow issue similar to #866 and #543. Compiling the code with -fno-ignore-interface-pragmas and -fenable-rewrite-rules or -O1 is a way around, but these optimizations are not available in the present etlas repl.

Expected Behavior

The code should run just fine.

Actual Behavior

The repl dumps a stack trace.

Possible Fix

As referred in this comment, one can re-write the code using trampolineIO or a stack managed IO approach.

Steps to Reproduce

  1. etlas repl
  2. Evaluate forM_ [0..4096] print

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions