Commit 85c17dbf authored by Tom Lane's avatar Tom Lane

Out-of-bounds memory allocation request sizes should be treated as just

elog(ERROR) not an Assert trap, since we've downgraded out-of-memory to
elog(ERROR) not a fatal error.  Also, change the hard boundary from 256Mb
to 1Gb, just so that anyone who's actually got that much memory to spare
can play with TOAST objects approaching a gigabyte.
parent 192ce19d
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/excid.c,v 1.9 2001/01/24 19:43:15 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/excid.c,v 1.10 2001/02/06 01:53:53 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -42,18 +42,6 @@ Exception BadArg = {"Bad Argument to Function Call"}; ...@@ -42,18 +42,6 @@ Exception BadArg = {"Bad Argument to Function Call"};
* Specific Recoverable Exceptions * * Specific Recoverable Exceptions *
*****************************************************************************/ *****************************************************************************/
/*
* BadAllocSize
* Indicates that an allocation request is of unreasonable size.
*/
Exception BadAllocSize = {"Too Large Allocation Request"};
/*
* ExhaustedMemory
* Indicates an dynamic memory allocation failed.
*/
Exception ExhaustedMemory = {"Memory Allocation Failed"};
/* /*
* Unimplemented * Unimplemented
* Indicates a function call request requires unimplemented code. * Indicates a function call request requires unimplemented code.
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.26 2001/01/24 19:43:16 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.27 2001/02/06 01:53:53 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -417,8 +417,9 @@ MemoryContextAlloc(MemoryContext context, Size size) ...@@ -417,8 +417,9 @@ MemoryContextAlloc(MemoryContext context, Size size)
{ {
AssertArg(MemoryContextIsValid(context)); AssertArg(MemoryContextIsValid(context));
LogTrap(!AllocSizeIsValid(size), BadAllocSize, if (!AllocSizeIsValid(size))
("size=%d [0x%x]", size, size)); elog(ERROR, "MemoryContextAlloc: invalid request size %lu",
(unsigned long) size);
return (*context->methods->alloc) (context, size); return (*context->methods->alloc) (context, size);
} }
...@@ -474,8 +475,9 @@ repalloc(void *pointer, Size size) ...@@ -474,8 +475,9 @@ repalloc(void *pointer, Size size)
AssertArg(MemoryContextIsValid(header->context)); AssertArg(MemoryContextIsValid(header->context));
LogTrap(!AllocSizeIsValid(size), BadAllocSize, if (!AllocSizeIsValid(size))
("size=%d [0x%x]", size, size)); elog(ERROR, "repalloc: invalid request size %lu",
(unsigned long) size);
return (*header->context->methods->realloc) (header->context, return (*header->context->methods->realloc) (header->context,
pointer, size); pointer, size);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: excid.h,v 1.8 2001/01/24 19:43:28 momjian Exp $ * $Id: excid.h,v 1.9 2001/02/06 01:53:52 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
extern Exception FailedAssertion; extern Exception FailedAssertion;
extern Exception BadState; extern Exception BadState;
extern Exception BadArg; extern Exception BadArg;
extern Exception BadAllocSize;
extern Exception ExhaustedMemory;
extern Exception Unimplemented; extern Exception Unimplemented;
extern Exception CatalogFailure;/* XXX inconsistent naming style */ extern Exception CatalogFailure;/* XXX inconsistent naming style */
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: memutils.h,v 1.41 2001/01/24 19:43:28 momjian Exp $ * $Id: memutils.h,v 1.42 2001/02/06 01:53:52 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -22,16 +22,17 @@ ...@@ -22,16 +22,17 @@
/* /*
* MaxAllocSize * MaxAllocSize
* Arbitrary limit on size of allocations. * Quasi-arbitrary limit on size of allocations.
* *
* Note: * Note:
* There is no guarantee that allocations smaller than MaxAllocSize * There is no guarantee that allocations smaller than MaxAllocSize
* will succeed. Allocation requests larger than MaxAllocSize will * will succeed. Allocation requests larger than MaxAllocSize will
* be summarily denied. * be summarily denied.
* *
* XXX This should be defined in a file of tunable constants. * XXX This is deliberately chosen to correspond to the limiting size
* of varlena objects under TOAST. See VARATT_MASK_SIZE in postgres.h.
*/ */
#define MaxAllocSize ((Size) 0xfffffff) /* 16G - 1 */ #define MaxAllocSize ((Size) 0x3fffffff) /* 1 gigabyte - 1 */
#define AllocSizeIsValid(size) (0 < (size) && (size) <= MaxAllocSize) #define AllocSizeIsValid(size) (0 < (size) && (size) <= MaxAllocSize)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment