diff --git a/flatparse.cabal b/flatparse.cabal
--- a/flatparse.cabal
+++ b/flatparse.cabal
@@ -5,7 +5,7 @@
 -- see: https://github.com/sol/hpack
 
 name:           flatparse
-version:        0.5.4.2
+version:        0.5.4.3
 synopsis:       High-performance parsing from strict bytestrings
 description:    @Flatparse@ is a high-performance parsing library for strict bytestring input. See the README for more information:
                 <https://github.com/AndrasKovacs/flatparse>.
@@ -63,7 +63,7 @@
       FlatParse.Examples.BasicLambda.Lexer
       FlatParse.Examples.BasicLambda.Parser
       FlatParse.Minimal
-      FlatParse.Minimal.Exception
+      FlatParse.Minimal.Internal
       FlatParse.Stateful
       FlatParse.Stateful.Addr
       FlatParse.Stateful.Base
diff --git a/src/FlatParse/Minimal.hs b/src/FlatParse/Minimal.hs
--- a/src/FlatParse/Minimal.hs
+++ b/src/FlatParse/Minimal.hs
@@ -16,7 +16,7 @@
 
 module FlatParse.Minimal (
     module FlatParse.Minimal
-  , module FlatParse.Minimal.Exception
+  , ParseException(..)
   , FlatParse.Common.Position.Pos(..)
   , FlatParse.Common.Position.endPos
   , FlatParse.Common.Position.addrToPos#
@@ -44,7 +44,7 @@
 import qualified FlatParse.Common.Numbers as Common
 import qualified FlatParse.Common.Switch as Common
 import FlatParse.Common.Position
-import FlatParse.Minimal.Exception
+import FlatParse.Minimal.Internal
 
 {-# inline parseError #-}
 -- | Throw the designated parse error.
@@ -196,7 +196,7 @@
 --   constructed from the input buffer!
 unsafeEmbedBasicIO :: FPB.ParserIO () a -> Parser a
 unsafeEmbedBasicIO = \(FPB.ParserT f) -> Parser \eob s st ->
-  case f (PlainForeignPtr (error "unsafeEmbedBasicIO: attempted to build ByteString from buffer")) eob s st of
+  case f undefinedFinalizer eob s st of
     (# st, (# (# !a, s #) | | #) #) -> (# a, s, st #)
     (# st, _                     #) -> parseError# st
 
diff --git a/src/FlatParse/Minimal/Exception.hs b/src/FlatParse/Minimal/Exception.hs
deleted file mode 100644
--- a/src/FlatParse/Minimal/Exception.hs
+++ /dev/null
@@ -1,14 +0,0 @@
-{-# language EmptyCase, PolyKinds, KindSignatures, RankNTypes #-}
-{-# options_ghc -Wno-incomplete-patterns #-}
-
-module FlatParse.Minimal.Exception where
-
-import GHC.Exts
-import Control.Exception
-
-data ParseException = ParseException deriving Show
-instance Exception ParseException
-
-{-# noinline parseError# #-}
-parseError# :: forall r (b :: TYPE r). State# RealWorld -> b
-parseError# = \st -> case raiseIO# (toException ParseException) st of
diff --git a/src/FlatParse/Minimal/Internal.hs b/src/FlatParse/Minimal/Internal.hs
new file mode 100644
--- /dev/null
+++ b/src/FlatParse/Minimal/Internal.hs
@@ -0,0 +1,24 @@
+{-# language EmptyCase, PolyKinds, KindSignatures, RankNTypes #-}
+{-# options_ghc -Wno-incomplete-patterns #-}
+
+module FlatParse.Minimal.Internal where
+
+import GHC.Exts
+import Control.Exception
+import Data.IORef
+import System.IO.Unsafe
+import GHC.ForeignPtr
+
+data ParseException = ParseException deriving Show
+instance Exception ParseException
+
+{-# noinline parseError# #-}
+parseError# :: forall r (b :: TYPE r). State# RealWorld -> b
+parseError# = \st -> case raiseIO# (toException ParseException) st of
+
+{-# noinline undefinedFinalizer #-}
+-- | Dummy finalizer for 'unsafeEmbedBasicIO'.
+undefinedFinalizer :: ForeignPtrContents -- IORef Finalizers
+undefinedFinalizer =
+  PlainForeignPtr $ unsafeDupablePerformIO $
+    newIORef $ error "unsafeEmbedBasicIO: attempted to build ByteString from buffer"
