From ed9b36c23194d97920ffdf97ef0573e92a7fdc36 Mon Sep 17 00:00:00 2001 From: max ulidtko Date: Fri, 3 Jul 2020 13:19:16 +0300 Subject: [PATCH] Drop unsafe from PQconsumeInput FFI import Some paths in PQconsumeInput can go into blocking I/O calls. This has really bad interactions with GC; the RTS ends up waiting on IO (potentially, network) before being able to start Garbage Collection -- meanwhile, any Haskell mutation is blocked all this time. See the related research in: https://gitlab.haskell.org/ghc/ghc/-/issues/18415 Regardless of further issues in GHC RTS -- this call *must not* be marked "unsafe". --- src/Database/PostgreSQL/LibPQ.hsc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Database/PostgreSQL/LibPQ.hsc b/src/Database/PostgreSQL/LibPQ.hsc index 9631290..88d9d0e 100644 --- a/src/Database/PostgreSQL/LibPQ.hsc +++ b/src/Database/PostgreSQL/LibPQ.hsc @@ -2510,7 +2510,7 @@ foreign import ccall "libpq-fe.h PQcancel" foreign import ccall unsafe "libpq-fe.h PQnotifies" c_PQnotifies :: Ptr PGconn -> IO (Ptr Notify) -foreign import ccall unsafe "libpq-fe.h PQconsumeInput" +foreign import ccall "libpq-fe.h PQconsumeInput" c_PQconsumeInput :: Ptr PGconn -> IO CInt foreign import ccall unsafe "libpq-fe.h PQisBusy"