I am reporting this here because it seems like some of the things I am seeing are probably not wai specific. Sorry for the length of this ticket, it tires to document various issues I encountered when several requests are executed concurrently/very close to each other by wai Jetty server.
I have a project using servant that now has been converted to eta:
https://github.com/rpeszek/crud-ex-backend-servant/tree/eta-jetty (eta-jetty branch)
It uses Raw WAI logic to serve static files, and I see somewhat different errors with 'true' servant endpoints like endpoints serving JSON.
Right after etlas run
if I first issue a single GET request like:
http://localhost:9000/static/css/pure.css
everything works fine. The first request takes some time to complete (warmup time typical of Java apps) but after that everything works and seems fast.
If right after starting the app I point my browser at: http://localhost:9000/elm# (which returns a full page) browser issues 4 GET request one for the page which completes and 3 for CSS and JS file which never complete (none of the 3 completes). It looks like a deadlock.
If that happens, nothing works until the app is restarted and I issue a simple isolated 'warm-up' request. No errors are printed in the console.
To troubleshoot I added some putStrLn "hello" lines (at the beginning of WAI.Application handler) to see if the line gets hit. Weirdly enough, with that change I get errors printed
2017-09-17 18:40:09.996:WARN:oejs.HttpChannel:qtp1468343491-15: /static/css/pure.css
eta.runtime.exception.EtaException: thread blocked indefinitely in an MVar operation
at resourcet.control.monad.trans.Resource$sat_s1FFQ.enter(Resource.hs:189)
at eta.runtime.apply.Function.applyPV(Function.java:120)
at eta.runtime.exception.Exception.catch_(Exception.java:174)
at resourcet.control.monad.trans.Resource$sat_s1FFR.enter(Resource.hs:188)
at eta.runtime.apply.Function.applyV(Function.java:16)
at base.ghc.Base$bindIO1.enter(Base.hs:1021)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at eta.runtime.exception.Exception.maskAsyncExceptions(Exception.java:42)
at resourcet.control.monad.trans.Resource$sat_s1FG4.enter(Resource.hs:187)
at eta.runtime.apply.Function.applyPV(Function.java:120)
at base.ghc.Base$bindIO1.enter(Base.hs:1067)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at base.ghc.Base$bindIO1.enter(Base.hs:1021)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at wai_servlet_handler_jetty.network.wai.servlet.handler.Jetty$sat_sRFP.enter(Jetty.hs:41)
at eta.runtime.apply.Function.applyO(Function.java:87)
at eta.runtime.thunk.Thunk.applyO(Thunk.java:146)
at base.java.TopHandler$runJava1.enter(TopHandler.hs:25)
at base.java.TopHandler$runJava.enter(TopHandler.hs)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyO(PAP.java:111)
at eta.runtime.stg.Closures$EvalJava.enter(Closures.java:149)
at eta.runtime.stg.Capability.schedule(Capability.java:156)
at eta.runtime.stg.Capability.scheduleClosure(Capability.java:101)
at eta.runtime.Runtime.evalJava(Runtime.java:201)
at eta.org.eclipse.jetty.server.handler.AbstractHandler$Eta.handle(Unknown Source)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:564)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
at java.lang.Thread.run(Thread.java:745)
Caused by:
eta.runtime.exception.EtaException: thread blocked indefinitely in an MVar operation
at eta.runtime.stg.Capability.detectMVarDeadlock(Capability.java:523)
at eta.runtime.stg.Capability.idleLoop(Capability.java:516)
at eta.runtime.stg.Capability.blockedLoop(Capability.java:534)
at eta.runtime.stg.Capability.blockedLoop(Capability.java:530)
at eta.runtime.concurrent.Concurrent.takeMVar(Concurrent.java:63)
at base.ghc.io.handle.Internals$$wa2.enter(Internals.hs:163)
at base.ghc.io.handle.Internals$a3_sG1VB.enter(Internals.hs:132)
at eta.runtime.apply.Function.applyV(Function.java:16)
at eta.runtime.exception.Exception.maskAsyncExceptions(Exception.java:42)
at base.ghc.io.handle.Internals$withHandlezq1.enter(Internals.hs:130)
at base.ghc.io.handle.Internals$wantWritableHandle2.enter(Internals.hs:236)
at base.ghc.io.handle.Internals$wantWritableHandle1.enter(Internals.hs:226)
at base.ghc.io.handle.Text$hPutStr2.enter(Text.hs:544)
at crud_ex_backend_servant.util.WaiStatic$$wa1.enter(WaiStatic.hs:30)
at crud_ex_backend_servant.util.StaticFiles$sat_s1HO6.enter(StaticFiles.hs:29)
at eta.runtime.apply.Function.applyPPV(Function.java:164)
at servant_server.servant.server.Internal$sat_s42PO.enter(Internal.hs:441)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at eta.runtime.exception.Exception.unmaskAsyncExceptions(Exception.java:91)
at resourcet.control.monad.trans.Resource$sat_s1FFK.enter(Resource.hs)
at eta.runtime.apply.Function.applyV(Function.java:16)
at eta.runtime.exception.Exception.catch_(Exception.java:136)
at resourcet.control.monad.trans.Resource$sat_s1FFR.enter(Resource.hs:188)
at eta.runtime.apply.Function.applyV(Function.java:16)
at base.ghc.Base$bindIO1.enter(Base.hs:1021)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at eta.runtime.exception.Exception.maskAsyncExceptions(Exception.java:42)
at resourcet.control.monad.trans.Resource$sat_s1FG4.enter(Resource.hs:187)
at eta.runtime.apply.Function.applyPV(Function.java:120)
at base.ghc.Base$bindIO1.enter(Base.hs:1067)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at base.ghc.Base$bindIO1.enter(Base.hs:1021)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at wai_servlet_handler_jetty.network.wai.servlet.handler.Jetty$sat_sRFP.enter(Jetty.hs:41)
at eta.runtime.apply.Function.applyO(Function.java:87)
at eta.runtime.thunk.Thunk.applyO(Thunk.java:146)
at base.java.TopHandler$runJava1.enter(TopHandler.hs:25)
at base.java.TopHandler$runJava.enter(TopHandler.hs)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyO(PAP.java:111)
at eta.runtime.stg.Closures$EvalJava.enter(Closures.java:149)
at eta.runtime.stg.Capability.schedule(Capability.java:156)
at eta.runtime.stg.Capability.scheduleClosure(Capability.java:101)
at eta.runtime.Runtime.evalJava(Runtime.java:201)
at eta.org.eclipse.jetty.server.handler.AbstractHandler$Eta.handle(Unknown Source)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:564)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
at java.lang.Thread.run(Thread.java:745)
2017-09-17 18:40:09.997:WARN:oejs.HttpChannel:qtp1468343491-11: /static/css/styles.css
eta.runtime.exception.EtaException: Exception was thrown in rendering exception of type class java.lang.NullPointerException
at resourcet.control.monad.trans.Resource$sat_s1FFQ.enter(Resource.hs:189)
at eta.runtime.apply.Function.applyPV(Function.java:120)
at eta.runtime.exception.Exception.catch_(Exception.java:174)
at resourcet.control.monad.trans.Resource$sat_s1FFR.enter(Resource.hs:188)
at eta.runtime.apply.Function.applyV(Function.java:16)
at base.ghc.Base$bindIO1.enter(Base.hs:1021)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at eta.runtime.exception.Exception.maskAsyncExceptions(Exception.java:42)
at resourcet.control.monad.trans.Resource$sat_s1FG4.enter(Resource.hs:187)
at eta.runtime.apply.Function.applyPV(Function.java:120)
at base.ghc.Base$bindIO1.enter(Base.hs:1067)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at base.ghc.Base$bindIO1.enter(Base.hs:1021)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at wai_servlet_handler_jetty.network.wai.servlet.handler.Jetty$sat_sRFP.enter(Jetty.hs:41)
at eta.runtime.apply.Function.applyO(Function.java:87)
at eta.runtime.thunk.Thunk.applyO(Thunk.java:146)
at base.java.TopHandler$runJava1.enter(TopHandler.hs:25)
at base.java.TopHandler$runJava.enter(TopHandler.hs)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyO(PAP.java:111)
at eta.runtime.stg.Closures$EvalJava.enter(Closures.java:149)
at eta.runtime.stg.Capability.schedule(Capability.java:156)
at eta.runtime.stg.Capability.scheduleClosure(Capability.java:101)
at eta.runtime.Runtime.evalJava(Runtime.java:201)
at eta.org.eclipse.jetty.server.handler.AbstractHandler$Eta.handle(Unknown Source)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:564)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
at java.lang.Thread.run(Thread.java:745)
Caused by:
eta.runtime.exception.EtaException: thread blocked indefinitely in an MVar operation
at eta.runtime.stg.Capability.detectMVarDeadlock(Capability.java:523)
at eta.runtime.stg.Capability.idleLoop(Capability.java:516)
at eta.runtime.stg.Capability.blockedLoop(Capability.java:534)
at eta.runtime.stg.Capability.blockedLoop(Capability.java:530)
at eta.runtime.concurrent.Concurrent.takeMVar(Concurrent.java:63)
at base.ghc.io.handle.Internals$$wa2.enter(Internals.hs:163)
at base.ghc.io.handle.Internals$a3_sG1VB.enter(Internals.hs:132)
at eta.runtime.apply.Function.applyV(Function.java:16)
at eta.runtime.exception.Exception.maskAsyncExceptions(Exception.java:42)
at base.ghc.io.handle.Internals$withHandlezq1.enter(Internals.hs:130)
at base.ghc.io.handle.Internals$wantWritableHandle2.enter(Internals.hs:236)
at base.ghc.io.handle.Internals$wantWritableHandle1.enter(Internals.hs:226)
at base.ghc.io.handle.Text$hPutStr2.enter(Text.hs:544)
at crud_ex_backend_servant.util.WaiStatic$$wa1.enter(WaiStatic.hs:30)
at crud_ex_backend_servant.util.StaticFiles$sat_s1HO6.enter(StaticFiles.hs:29)
at eta.runtime.apply.Function.applyPPV(Function.java:164)
at servant_server.servant.server.Internal$sat_s42PO.enter(Internal.hs:441)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at eta.runtime.exception.Exception.unmaskAsyncExceptions(Exception.java:91)
at resourcet.control.monad.trans.Resource$sat_s1FFK.enter(Resource.hs)
at eta.runtime.apply.Function.applyV(Function.java:16)
at eta.runtime.exception.Exception.catch_(Exception.java:136)
at resourcet.control.monad.trans.Resource$sat_s1FFR.enter(Resource.hs:188)
at eta.runtime.apply.Function.applyV(Function.java:16)
at base.ghc.Base$bindIO1.enter(Base.hs:1021)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at eta.runtime.exception.Exception.maskAsyncExceptions(Exception.java:42)
at resourcet.control.monad.trans.Resource$sat_s1FG4.enter(Resource.hs:187)
at eta.runtime.apply.Function.applyPV(Function.java:120)
at base.ghc.Base$bindIO1.enter(Base.hs:1067)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at base.ghc.Base$bindIO1.enter(Base.hs:1021)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at wai_servlet_handler_jetty.network.wai.servlet.handler.Jetty$sat_sRFP.enter(Jetty.hs:41)
at eta.runtime.apply.Function.applyO(Function.java:87)
at eta.runtime.thunk.Thunk.applyO(Thunk.java:146)
at base.java.TopHandler$runJava1.enter(TopHandler.hs:25)
at base.java.TopHandler$runJava.enter(TopHandler.hs)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyO(PAP.java:111)
at eta.runtime.stg.Closures$EvalJava.enter(Closures.java:149)
at eta.runtime.stg.Capability.schedule(Capability.java:156)
at eta.runtime.stg.Capability.scheduleClosure(Capability.java:101)
at eta.runtime.Runtime.evalJava(Runtime.java:201)
at eta.org.eclipse.jetty.server.handler.AbstractHandler$Eta.handle(Unknown Source)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:564)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
at java.lang.Thread.run(Thread.java:745)
(here pure.css returned 500 and remaining 2 never returned).
I see no errors if putStrLn is removed or if requests are run in isolation. I see the printouts with or without warmup (with warmup fewer printouts and more intermittent). If requests are run in isolation everything works. However once the errors are encountered server stops responding and printing anything. suggesting that serving threads are dead.
MemoryManager:
Adding putStrLn to a JSON handler (true Servant endpoint) produces another strange behavior. No error are printed in JSON request is executed in isolation.
However if it is accompanied with other requests (like CSS files, etc) I get this error:
2017-09-17 16:12:02.603:WARN:oejs.HttpChannel:qtp1468343491-16: /things
eta.runtime.exception.EtaException: JException java.lang.IllegalStateException: The block that corresponds to the address 1048587 is not allocated in memory
at resourcet.control.monad.trans.Resource$sat_s1FFQ.enter(Resource.hs:189)
at eta.runtime.apply.Function.applyPV(Function.java:120)
at eta.runtime.exception.Exception.catch_(Exception.java:174)
at resourcet.control.monad.trans.Resource$sat_s1FFR.enter(Resource.hs:188)
at eta.runtime.apply.Function.applyV(Function.java:16)
at base.ghc.Base$bindIO1.enter(Base.hs:1021)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at eta.runtime.exception.Exception.maskAsyncExceptions(Exception.java:42)
at resourcet.control.monad.trans.Resource$sat_s1FG4.enter(Resource.hs:187)
at eta.runtime.apply.Function.applyPV(Function.java:120)
at base.ghc.Base$bindIO1.enter(Base.hs:1067)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at base.ghc.Base$bindIO1.enter(Base.hs:1021)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at wai_servlet_handler_jetty.network.wai.servlet.handler.Jetty$sat_sRFP.enter(Jetty.hs:41)
at eta.runtime.apply.Function.applyO(Function.java:87)
at eta.runtime.thunk.Thunk.applyO(Thunk.java:146)
at base.java.TopHandler$runJava1.enter(TopHandler.hs:25)
at base.java.TopHandler$runJava.enter(TopHandler.hs)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyO(PAP.java:111)
at eta.runtime.stg.Closures$EvalJava.enter(Closures.java:149)
at eta.runtime.stg.Capability.schedule(Capability.java:156)
at eta.runtime.stg.Capability.scheduleClosure(Capability.java:101)
at eta.runtime.Runtime.evalJava(Runtime.java:201)
at eta.org.eclipse.jetty.server.handler.AbstractHandler$Eta.handle(Unknown Source)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:564)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
at java.lang.Thread.run(Thread.java:745)
Caused by:
java.lang.IllegalStateException: The block that corresponds to the address 1048587 is not allocated in memory
at eta.runtime.io.MemoryManager.getBoundedBuffer(MemoryManager.java:615)
at eta.bytestring.Utils.memcmp(Utils.java:46)
at bytestring.data.bytestring.Internal$$wcompareBytes.enter(Internal.hs:594)
at http_media.network.http.media.mediatype.Internal$$w$cparseAccept.enter(Internal.hs:47)
at http_media.network.http.Media$mapAcceptMedia_go.enter(Media.hs:235)
at http_media.network.http.Media$$w$sparseQuality.enter(Media.hs:232)
at crud_ex_backend_servant.crudex.Server$$Lr2SVZZ$wlvl18.enter(Server.hs)
at crud_ex_backend_servant.crudex.Server$$Lr2SW0lvl49.enter(Server.hs)
at eta.runtime.apply.Function.applyPPP(Function.java:190)
at servant_server.servant.server.Internal$sat_s40K8.enter(Internal.hs:220)
at eta.runtime.apply.Function.applyP(Function.java:102)
at servant_server.servant.server.internal.RoutingApplication$sat_s1X8U.enter(RoutingApplication.hs:379)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at eta.runtime.exception.Exception.unmaskAsyncExceptions(Exception.java:91)
at resourcet.control.monad.trans.Resource$sat_s1FFK.enter(Resource.hs)
at eta.runtime.apply.Function.applyV(Function.java:16)
at eta.runtime.exception.Exception.catch_(Exception.java:136)
at resourcet.control.monad.trans.Resource$sat_s1FFR.enter(Resource.hs:188)
at eta.runtime.apply.Function.applyV(Function.java:16)
at base.ghc.Base$bindIO1.enter(Base.hs:1021)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at eta.runtime.exception.Exception.maskAsyncExceptions(Exception.java:42)
at resourcet.control.monad.trans.Resource$sat_s1FG4.enter(Resource.hs:187)
at eta.runtime.apply.Function.applyPV(Function.java:120)
at base.ghc.Base$bindIO1.enter(Base.hs:1067)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at base.ghc.Base$bindIO1.enter(Base.hs:1021)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at wai_servlet_handler_jetty.network.wai.servlet.handler.Jetty$sat_sRFP.enter(Jetty.hs:41)
at eta.runtime.apply.Function.applyO(Function.java:87)
at eta.runtime.thunk.Thunk.applyO(Thunk.java:146)
at base.java.TopHandler$runJava1.enter(TopHandler.hs:25)
at base.java.TopHandler$runJava.enter(TopHandler.hs)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyO(PAP.java:111)
at eta.runtime.stg.Closures$EvalJava.enter(Closures.java:149)
at eta.runtime.stg.Capability.schedule(Capability.java:156)
at eta.runtime.stg.Capability.scheduleClosure(Capability.java:101)
at eta.runtime.Runtime.evalJava(Runtime.java:201)
at eta.org.eclipse.jetty.server.handler.AbstractHandler$Eta.handle(Unknown Source)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:564)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
at java.lang.Thread.run(Thread.java:745)
I sometimes see this super puzzling error that does not even have any of my code in the stack trace:
2017-09-17 13:41:33.517:WARN:oejs.HttpChannel:qtp2114537280-11: /things
eta.runtime.exception.EtaException: JException java.nio.BufferUnderflowException
at resourcet.control.monad.trans.Resource$sat_s1FFQ.enter(Resource.hs:189)
at eta.runtime.apply.Function.applyPV(Function.java:120)
at eta.runtime.exception.Exception.catch_(Exception.java:174)
at resourcet.control.monad.trans.Resource$sat_s1FFR.enter(Resource.hs:188)
at eta.runtime.apply.Function.applyV(Function.java:16)
at base.ghc.Base$bindIO1.enter(Base.hs:1021)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at eta.runtime.exception.Exception.maskAsyncExceptions(Exception.java:42)
at resourcet.control.monad.trans.Resource$sat_s1FG4.enter(Resource.hs:187)
at eta.runtime.apply.Function.applyPV(Function.java:120)
at base.ghc.Base$bindIO1.enter(Base.hs:1067)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at base.ghc.Base$bindIO1.enter(Base.hs:1021)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at wai_servlet_handler_jetty.network.wai.servlet.handler.Jetty$sat_sRFP.enter(Jetty.hs:41)
at eta.runtime.apply.Function.applyO(Function.java:87)
at eta.runtime.thunk.Thunk.applyO(Thunk.java:146)
at base.java.TopHandler$runJava1.enter(TopHandler.hs:25)
at base.java.TopHandler$runJava.enter(TopHandler.hs)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyO(PAP.java:111)
at eta.runtime.stg.Closures$EvalJava.enter(Closures.java:149)
at eta.runtime.stg.Capability.schedule(Capability.java:156)
at eta.runtime.stg.Capability.scheduleClosure(Capability.java:101)
at eta.runtime.Runtime.evalJava(Runtime.java:201)
at eta.org.eclipse.jetty.server.handler.AbstractHandler$Eta.handle(Unknown Source)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:564)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
at java.lang.Thread.run(Thread.java:745)
Caused by:
java.nio.BufferUnderflowException
at java.nio.Buffer.nextGetIndex(Buffer.java:500)
at java.nio.DirectByteBuffer.get(DirectByteBuffer.java:249)
at eta.bytestring.Utils.memcmp(Utils.java:50)
at bytestring.data.bytestring.Internal$$wcompareBytes.enter(Internal.hs:594)
at http_media.network.http.media.mediatype.Internal$$w$cparseAccept.enter(Internal.hs:47)
at http_media.network.http.Media$mapAcceptMedia_go.enter(Media.hs:235)
at http_media.network.http.Media$$w$sparseQuality.enter(Media.hs:232)
at servant_server.servant.server.Internal$v_s40IY.thunkEnter(Internal.hs:205)
at eta.runtime.thunk.UpdatableThunk.enter(UpdatableThunk.java:18)
at eta.runtime.thunk.Thunk.applyP(Thunk.java:151)
at servant_server.servant.server.Internal$eta1_s40JA.thunkEnter(Internal.hs)
at eta.runtime.thunk.UpdatableThunk.enter(UpdatableThunk.java:18)
at eta.runtime.thunk.Thunk.applyP(Thunk.java:151)
at servant_server.servant.server.Internal$sat_s40JM.thunkEnter(Internal.hs)
at eta.runtime.thunk.UpdatableThunk.enter(UpdatableThunk.java:18)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at base.ghc.Base$bindIO1.enter(Base.hs:1021)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.apply.Function.applyPV(Function.java:117)
at base.ghc.Base$bindIO1.enter(Base.hs:1067)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.apply.Function.applyPV(Function.java:117)
at eta.runtime.apply.Function.applyPPV(Function.java:156)
at servant_server.servant.server.internal.RoutingApplication$sat_s1X7V.enter(RoutingApplication.hs:215)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyPV(PAP.java:142)
at eta.runtime.thunk.Thunk.applyPV(Thunk.java:156)
at servant_server.servant.server.internal.RoutingApplication$sat_s1X8U.enter(RoutingApplication.hs:370)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at eta.runtime.exception.Exception.unmaskAsyncExceptions(Exception.java:91)
at resourcet.control.monad.trans.Resource$sat_s1FFK.enter(Resource.hs)
at eta.runtime.apply.Function.applyV(Function.java:16)
at eta.runtime.exception.Exception.catch_(Exception.java:136)
at resourcet.control.monad.trans.Resource$sat_s1FFR.enter(Resource.hs:188)
at eta.runtime.apply.Function.applyV(Function.java:16)
at base.ghc.Base$bindIO1.enter(Base.hs:1021)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at eta.runtime.exception.Exception.maskAsyncExceptions(Exception.java:42)
at resourcet.control.monad.trans.Resource$sat_s1FG4.enter(Resource.hs:187)
at eta.runtime.apply.Function.applyPV(Function.java:120)
at base.ghc.Base$bindIO1.enter(Base.hs:1067)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at base.ghc.Base$bindIO1.enter(Base.hs:1021)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at wai_servlet_handler_jetty.network.wai.servlet.handler.Jetty$sat_sRFP.enter(Jetty.hs:41)
at eta.runtime.apply.Function.applyO(Function.java:87)
at eta.runtime.thunk.Thunk.applyO(Thunk.java:146)
at base.java.TopHandler$runJava1.enter(TopHandler.hs:25)
at base.java.TopHandler$runJava.enter(TopHandler.hs)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyO(PAP.java:111)
at eta.runtime.stg.Closures$EvalJava.enter(Closures.java:149)
at eta.runtime.stg.Capability.schedule(Capability.java:156)
at eta.runtime.stg.Capability.scheduleClosure(Capability.java:101)
at eta.runtime.Runtime.evalJava(Runtime.java:201)
at eta.org.eclipse.jetty.server.handler.AbstractHandler$Eta.handle(Unknown Source)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:564)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
at java.lang.Thread.run(Thread.java:745)
Is putStrLn not safe to use here?
I modified https://github.com/rahulmutt/eta-servant-example code like so:
hello :: Maybe String -> Handler HelloMessage
hello mname = do
_ <- liftIO $ putStrLn "Hello"
return . HelloMessage $ case mname of
Nothing -> "Hello, anonymous coward"
Just n -> "Hello, " ++ n
By issuing 2 requests very close to each other right after app start:
http://localhost:9000/invalid
http://localhost:9000/hello
I can get this error:
2017-09-17 16:50:31.686:WARN:oejs.HttpChannel:qtp1987360300-10: /hello
eta.runtime.exception.RuntimeInternalError: |[Eta v0.0.9b1] ap_p|Please report this as a bug: https://github.com/typelead/eta/issues
at eta.runtime.RuntimeLogging.barf(RuntimeLogging.java:15)
at eta.runtime.stg.Closure.applyP(Closure.java:62)
at eta.runtime.thunk.Thunk.applyP(Thunk.java:151)
at main.Main$sat_s3EDC.thunkEnter(Main.hs)
at eta.runtime.thunk.UpdatableThunk.enter(UpdatableThunk.java:18)
at eta.runtime.thunk.Thunk.applyP(Thunk.java:151)
at bytestring.data.bytestring.builder.Internal$sat_s490T.enter(Internal.hs:391)
at eta.runtime.apply.Function.applyV(Function.java:16)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at base.ghc.IO$unsafeDupablePerformIO.enter(IO.hs:182)
at bytestring.data.bytestring.builder.Internal$toLazzyByteStringWith.enter(Internal.hs:248)
at bytestring.data.bytestring.Builder$toLazzyByteString.enter(Builder.hs:281)
at main.Main$$s$fAllCTRender_ZC_a_$s$fMimeRender_zt_JSON_a_$cmimeRender2.enter(Main.hs)
at eta.runtime.apply.Function.applyPP(Function.java:139)
at servant.servant.api.ContentTypes$bs_s1TVC.thunkEnter(ContentTypes.hs:277)
at eta.runtime.thunk.UpdatableThunk.enter(UpdatableThunk.java:18)
at servant_server.servant.server.Internal$sat_s40K5.thunkEnter(Internal.hs:189)
at eta.runtime.thunk.UpdatableThunk.enter(UpdatableThunk.java:18)
at eta.runtime.stg.Closure.evaluate(Closure.java:24)
at wai.network.Wai$responseLBS1.enter(Wai.hs)
at servant_server.servant.server.Internal$sat_s40K6.enter(Internal.hs)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyPV(PAP.java:142)
at blaze_builder.blaze.bytestring.Builder$$wa2_s1GQB.enter(Builder.hs)
at blaze_builder.blaze.bytestring.Builder$sat_s1GUH.enter(Builder.hs:246)
at eta.runtime.apply.Function.applyV(Function.java:16)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at base.ghc.IO$unsafeDupablePerformIO.enter(IO.hs:182)
at blaze_builder.blaze.bytestring.Builder$$wtoLazzyByteStringWith.enter(Builder.hs:245)
at wai_servlet.network.wai.servlet.Response$$wa.enter(Response.hs:61)
at wai_servlet.network.wai.servlet.Response$updateHttpServletResponse1.enter(Response.hs)
at wai_servlet_handler_jetty.network.wai.servlet.handler.Jetty$sat_sRFE.enter(Jetty.hs:46)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.apply.Function.applyPV(Function.java:117)
at servant_server.servant.server.internal.RoutingApplication$sat_s1X8U.enter(RoutingApplication.hs:371)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at eta.runtime.exception.Exception.unmaskAsyncExceptions(Exception.java:91)
at resourcet.control.monad.trans.Resource$sat_s1FFK.enter(Resource.hs)
at eta.runtime.apply.Function.applyV(Function.java:16)
at eta.runtime.exception.Exception.catch_(Exception.java:136)
at resourcet.control.monad.trans.Resource$sat_s1FFR.enter(Resource.hs:188)
at eta.runtime.apply.Function.applyV(Function.java:16)
at base.ghc.Base$bindIO1.enter(Base.hs:1021)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at eta.runtime.exception.Exception.maskAsyncExceptions(Exception.java:42)
at resourcet.control.monad.trans.Resource$sat_s1FG4.enter(Resource.hs:187)
at eta.runtime.apply.Function.applyPV(Function.java:120)
at base.ghc.Base$bindIO1.enter(Base.hs:1067)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at base.ghc.Base$bindIO1.enter(Base.hs:1021)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyV(PAP.java:41)
at eta.runtime.thunk.Thunk.applyV(Thunk.java:121)
at wai_servlet_handler_jetty.network.wai.servlet.handler.Jetty$sat_sRFP.enter(Jetty.hs:41)
at eta.runtime.apply.Function.applyO(Function.java:87)
at eta.runtime.thunk.Thunk.applyO(Thunk.java:146)
at base.java.TopHandler$runJava1.enter(TopHandler.hs:25)
at base.java.TopHandler$runJava.enter(TopHandler.hs)
at eta.runtime.apply.PAP.apply(PAP.java:31)
at eta.runtime.apply.PAP.applyO(PAP.java:111)
at eta.runtime.stg.Closures$EvalJava.enter(Closures.java:149)
at eta.runtime.stg.Capability.schedule(Capability.java:156)
at eta.runtime.stg.Capability.scheduleClosure(Capability.java:101)
at eta.runtime.Runtime.evalJava(Runtime.java:201)
at eta.org.eclipse.jetty.server.handler.AbstractHandler$Eta.handle(Unknown Source)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:564)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128)
at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590)
at java.lang.Thread.run(Thread.java:745)
Hello
bug