Skip to content

Commit e794dfa

Browse files
committed
Use an always-there test, not an Assert, to check for overrun of
the held_lwlocks[] array. Per Qingqing Zhou.
1 parent eb4b7a0 commit e794dfa

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/backend/storage/lmgr/lwlock.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Portions Copyright (c) 1994, Regents of the University of California
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.25 2004/12/31 22:01:05 pgsql Exp $
18+
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.26 2005/04/08 03:43:54 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -328,7 +328,8 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
328328
SpinLockRelease_NoHoldoff(&lock->mutex);
329329

330330
/* Add lock to list of locks held by this backend */
331-
Assert(num_held_lwlocks < MAX_SIMUL_LWLOCKS);
331+
if (num_held_lwlocks >= MAX_SIMUL_LWLOCKS)
332+
elog(ERROR, "too many LWLocks taken");
332333
held_lwlocks[num_held_lwlocks++] = lockid;
333334

334335
/*
@@ -397,7 +398,8 @@ LWLockConditionalAcquire(LWLockId lockid, LWLockMode mode)
397398
else
398399
{
399400
/* Add lock to list of locks held by this backend */
400-
Assert(num_held_lwlocks < MAX_SIMUL_LWLOCKS);
401+
if (num_held_lwlocks >= MAX_SIMUL_LWLOCKS)
402+
elog(ERROR, "too many LWLocks taken");
401403
held_lwlocks[num_held_lwlocks++] = lockid;
402404
}
403405

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy