diff --git a/capnp.cabal b/capnp.cabal
--- a/capnp.cabal
+++ b/capnp.cabal
@@ -1,6 +1,6 @@
 cabal-version:            2.2
 name:                     capnp
-version:                  0.10.0.0
+version:                  0.10.0.1
 category:                 Data, Serialization, Network, Rpc
 copyright:                2016-2020 haskell-capnp contributors (see CONTRIBUTORS file).
 author:                   Ian Denhardt
diff --git a/examples/gen/lib/Capnp/Gen/ById/X85150b117366d14b.hs b/examples/gen/lib/Capnp/Gen/ById/X85150b117366d14b.hs
--- a/examples/gen/lib/Capnp/Gen/ById/X85150b117366d14b.hs
+++ b/examples/gen/lib/Capnp/Gen/ById/X85150b117366d14b.hs
@@ -3,6 +3,7 @@
 {-# OPTIONS_GHC -Wno-unused-matches #-}
 {-# OPTIONS_GHC -Wno-orphans #-}
 {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
+{-# OPTIONS_GHC -Wno-name-shadowing #-}
 module Capnp.Gen.ById.X85150b117366d14b(module Capnp.Gen.Calculator) where
 import Capnp.Gen.Calculator
 import qualified Prelude as Std_
diff --git a/examples/gen/lib/Capnp/Gen/ById/X85150b117366d14b/Pure.hs b/examples/gen/lib/Capnp/Gen/ById/X85150b117366d14b/Pure.hs
--- a/examples/gen/lib/Capnp/Gen/ById/X85150b117366d14b/Pure.hs
+++ b/examples/gen/lib/Capnp/Gen/ById/X85150b117366d14b/Pure.hs
@@ -3,6 +3,7 @@
 {-# OPTIONS_GHC -Wno-unused-matches #-}
 {-# OPTIONS_GHC -Wno-orphans #-}
 {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
+{-# OPTIONS_GHC -Wno-name-shadowing #-}
 module Capnp.Gen.ById.X85150b117366d14b.Pure(module Capnp.Gen.Calculator.Pure) where
 import Capnp.Gen.Calculator.Pure
 import qualified Prelude as Std_
diff --git a/examples/gen/lib/Capnp/Gen/ById/Xd0a87f36fa0182f5.hs b/examples/gen/lib/Capnp/Gen/ById/Xd0a87f36fa0182f5.hs
--- a/examples/gen/lib/Capnp/Gen/ById/Xd0a87f36fa0182f5.hs
+++ b/examples/gen/lib/Capnp/Gen/ById/Xd0a87f36fa0182f5.hs
@@ -3,6 +3,7 @@
 {-# OPTIONS_GHC -Wno-unused-matches #-}
 {-# OPTIONS_GHC -Wno-orphans #-}
 {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
+{-# OPTIONS_GHC -Wno-name-shadowing #-}
 module Capnp.Gen.ById.Xd0a87f36fa0182f5(module Capnp.Gen.Echo) where
 import Capnp.Gen.Echo
 import qualified Prelude as Std_
diff --git a/examples/gen/lib/Capnp/Gen/ById/Xd0a87f36fa0182f5/Pure.hs b/examples/gen/lib/Capnp/Gen/ById/Xd0a87f36fa0182f5/Pure.hs
--- a/examples/gen/lib/Capnp/Gen/ById/Xd0a87f36fa0182f5/Pure.hs
+++ b/examples/gen/lib/Capnp/Gen/ById/Xd0a87f36fa0182f5/Pure.hs
@@ -3,6 +3,7 @@
 {-# OPTIONS_GHC -Wno-unused-matches #-}
 {-# OPTIONS_GHC -Wno-orphans #-}
 {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
+{-# OPTIONS_GHC -Wno-name-shadowing #-}
 module Capnp.Gen.ById.Xd0a87f36fa0182f5.Pure(module Capnp.Gen.Echo.Pure) where
 import Capnp.Gen.Echo.Pure
 import qualified Prelude as Std_
diff --git a/examples/gen/lib/Capnp/Gen/Calculator.hs b/examples/gen/lib/Capnp/Gen/Calculator.hs
--- a/examples/gen/lib/Capnp/Gen/Calculator.hs
+++ b/examples/gen/lib/Capnp/Gen/Calculator.hs
@@ -10,6 +10,7 @@
 {-# OPTIONS_GHC -Wno-unused-matches #-}
 {-# OPTIONS_GHC -Wno-orphans #-}
 {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
+{-# OPTIONS_GHC -Wno-name-shadowing #-}
 module Capnp.Gen.Calculator where
 import qualified Capnp.Message as Message
 import qualified Capnp.Untyped as Untyped
diff --git a/examples/gen/lib/Capnp/Gen/Calculator/Pure.hs b/examples/gen/lib/Capnp/Gen/Calculator/Pure.hs
--- a/examples/gen/lib/Capnp/Gen/Calculator/Pure.hs
+++ b/examples/gen/lib/Capnp/Gen/Calculator/Pure.hs
@@ -13,6 +13,7 @@
 {-# OPTIONS_GHC -Wno-unused-matches #-}
 {-# OPTIONS_GHC -Wno-orphans #-}
 {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
+{-# OPTIONS_GHC -Wno-name-shadowing #-}
 module Capnp.Gen.Calculator.Pure(Capnp.Gen.ById.X85150b117366d14b.Operator(..)
                                 ,Calculator(..)
                                 ,Calculator'server_(..)
diff --git a/examples/gen/lib/Capnp/Gen/Echo.hs b/examples/gen/lib/Capnp/Gen/Echo.hs
--- a/examples/gen/lib/Capnp/Gen/Echo.hs
+++ b/examples/gen/lib/Capnp/Gen/Echo.hs
@@ -10,6 +10,7 @@
 {-# OPTIONS_GHC -Wno-unused-matches #-}
 {-# OPTIONS_GHC -Wno-orphans #-}
 {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
+{-# OPTIONS_GHC -Wno-name-shadowing #-}
 module Capnp.Gen.Echo where
 import qualified Capnp.Message as Message
 import qualified Capnp.Untyped as Untyped
diff --git a/examples/gen/lib/Capnp/Gen/Echo/Pure.hs b/examples/gen/lib/Capnp/Gen/Echo/Pure.hs
--- a/examples/gen/lib/Capnp/Gen/Echo/Pure.hs
+++ b/examples/gen/lib/Capnp/Gen/Echo/Pure.hs
@@ -13,6 +13,7 @@
 {-# OPTIONS_GHC -Wno-unused-matches #-}
 {-# OPTIONS_GHC -Wno-orphans #-}
 {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
+{-# OPTIONS_GHC -Wno-name-shadowing #-}
 module Capnp.Gen.Echo.Pure(Echo(..)
                           ,Echo'server_(..)
                           ,export_Echo
diff --git a/gen/tests/Capnp/Gen/Aircraft.hs b/gen/tests/Capnp/Gen/Aircraft.hs
--- a/gen/tests/Capnp/Gen/Aircraft.hs
+++ b/gen/tests/Capnp/Gen/Aircraft.hs
@@ -10,6 +10,7 @@
 {-# OPTIONS_GHC -Wno-unused-matches #-}
 {-# OPTIONS_GHC -Wno-orphans #-}
 {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
+{-# OPTIONS_GHC -Wno-name-shadowing #-}
 module Capnp.Gen.Aircraft where
 import qualified Capnp.Message as Message
 import qualified Capnp.Untyped as Untyped
diff --git a/gen/tests/Capnp/Gen/Aircraft/Pure.hs b/gen/tests/Capnp/Gen/Aircraft/Pure.hs
--- a/gen/tests/Capnp/Gen/Aircraft/Pure.hs
+++ b/gen/tests/Capnp/Gen/Aircraft/Pure.hs
@@ -13,6 +13,7 @@
 {-# OPTIONS_GHC -Wno-unused-matches #-}
 {-# OPTIONS_GHC -Wno-orphans #-}
 {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
+{-# OPTIONS_GHC -Wno-name-shadowing #-}
 module Capnp.Gen.Aircraft.Pure(Capnp.Gen.ById.X832bcc6686a26d56.Airport(..)
                               ,constDate
                               ,constList
diff --git a/gen/tests/Capnp/Gen/ById/X832bcc6686a26d56.hs b/gen/tests/Capnp/Gen/ById/X832bcc6686a26d56.hs
--- a/gen/tests/Capnp/Gen/ById/X832bcc6686a26d56.hs
+++ b/gen/tests/Capnp/Gen/ById/X832bcc6686a26d56.hs
@@ -3,6 +3,7 @@
 {-# OPTIONS_GHC -Wno-unused-matches #-}
 {-# OPTIONS_GHC -Wno-orphans #-}
 {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
+{-# OPTIONS_GHC -Wno-name-shadowing #-}
 module Capnp.Gen.ById.X832bcc6686a26d56(module Capnp.Gen.Aircraft) where
 import Capnp.Gen.Aircraft
 import qualified Prelude as Std_
diff --git a/gen/tests/Capnp/Gen/ById/X832bcc6686a26d56/Pure.hs b/gen/tests/Capnp/Gen/ById/X832bcc6686a26d56/Pure.hs
--- a/gen/tests/Capnp/Gen/ById/X832bcc6686a26d56/Pure.hs
+++ b/gen/tests/Capnp/Gen/ById/X832bcc6686a26d56/Pure.hs
@@ -3,6 +3,7 @@
 {-# OPTIONS_GHC -Wno-unused-matches #-}
 {-# OPTIONS_GHC -Wno-orphans #-}
 {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
+{-# OPTIONS_GHC -Wno-name-shadowing #-}
 module Capnp.Gen.ById.X832bcc6686a26d56.Pure(module Capnp.Gen.Aircraft.Pure) where
 import Capnp.Gen.Aircraft.Pure
 import qualified Prelude as Std_
diff --git a/gen/tests/Capnp/Gen/ById/Xb6421fb8e478d144.hs b/gen/tests/Capnp/Gen/ById/Xb6421fb8e478d144.hs
--- a/gen/tests/Capnp/Gen/ById/Xb6421fb8e478d144.hs
+++ b/gen/tests/Capnp/Gen/ById/Xb6421fb8e478d144.hs
@@ -3,6 +3,7 @@
 {-# OPTIONS_GHC -Wno-unused-matches #-}
 {-# OPTIONS_GHC -Wno-orphans #-}
 {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
+{-# OPTIONS_GHC -Wno-name-shadowing #-}
 module Capnp.Gen.ById.Xb6421fb8e478d144(module Capnp.Gen.Generics) where
 import Capnp.Gen.Generics
 import qualified Prelude as Std_
diff --git a/gen/tests/Capnp/Gen/ById/Xb6421fb8e478d144/Pure.hs b/gen/tests/Capnp/Gen/ById/Xb6421fb8e478d144/Pure.hs
--- a/gen/tests/Capnp/Gen/ById/Xb6421fb8e478d144/Pure.hs
+++ b/gen/tests/Capnp/Gen/ById/Xb6421fb8e478d144/Pure.hs
@@ -3,6 +3,7 @@
 {-# OPTIONS_GHC -Wno-unused-matches #-}
 {-# OPTIONS_GHC -Wno-orphans #-}
 {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
+{-# OPTIONS_GHC -Wno-name-shadowing #-}
 module Capnp.Gen.ById.Xb6421fb8e478d144.Pure(module Capnp.Gen.Generics.Pure) where
 import Capnp.Gen.Generics.Pure
 import qualified Prelude as Std_
diff --git a/gen/tests/Capnp/Gen/Generics.hs b/gen/tests/Capnp/Gen/Generics.hs
--- a/gen/tests/Capnp/Gen/Generics.hs
+++ b/gen/tests/Capnp/Gen/Generics.hs
@@ -10,6 +10,7 @@
 {-# OPTIONS_GHC -Wno-unused-matches #-}
 {-# OPTIONS_GHC -Wno-orphans #-}
 {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
+{-# OPTIONS_GHC -Wno-name-shadowing #-}
 module Capnp.Gen.Generics where
 import qualified Capnp.Message as Message
 import qualified Capnp.Untyped as Untyped
diff --git a/gen/tests/Capnp/Gen/Generics/Pure.hs b/gen/tests/Capnp/Gen/Generics/Pure.hs
--- a/gen/tests/Capnp/Gen/Generics/Pure.hs
+++ b/gen/tests/Capnp/Gen/Generics/Pure.hs
@@ -13,6 +13,7 @@
 {-# OPTIONS_GHC -Wno-unused-matches #-}
 {-# OPTIONS_GHC -Wno-orphans #-}
 {-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
+{-# OPTIONS_GHC -Wno-name-shadowing #-}
 module Capnp.Gen.Generics.Pure(Maybe(..)
                               ,Either(..)
                               ,Pair(..)
diff --git a/lib/Capnp/Message.hs b/lib/Capnp/Message.hs
--- a/lib/Capnp/Message.hs
+++ b/lib/Capnp/Message.hs
@@ -515,9 +515,10 @@
         Nothing -> do
             -- Not enough space in the current segment; allocate a new one.
             -- the new segment's size should match the total size of existing segments
+            -- but `maxSegmentSize` bounds how large it can get.
             WordCount totalAllocation <- sum <$>
                 traverse (getSegment msg >=> numWords) [0..segIndex]
-            ( newSegIndex, _ ) <- newSegment msg (max totalAllocation sizeInt)
+            ( newSegIndex, _ ) <- newSegment msg (min (max totalAllocation sizeInt) maxSegmentSize)
             -- This is guaranteed to succeed, since we just made a segment with
             -- at least size available space:
             fromJust <$> allocInSeg msg newSegIndex size
