RemoveLocalLock pfree'ing NULL when out-of-memory

From: Andreas Seltenreich <seltenreich(at)gmx(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Subject: RemoveLocalLock pfree'ing NULL when out-of-memory
Date: 2015-09-20 18:39:03
Message-ID: 87d1xdey0o.fsf@ex.ansel.ydns.eu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

a memory-starved instance of sqlsmith just caught RemoveLocalLock
pfree'ing a NULL in locallock->lockOwners. I think what happened is
that it was called to clean up after LockAcquireExtended's
MemoryContextAlloc failed. The content of errordata seems consistent
with this.

Caught in master as of 85eda7e (sorry about the bogus hashes in earlier
reports, I had some cruft on my local branch).

regards,
Andreas

FailedAssertion("!(pointer != ((void *)0))", File: "mcxt.c", Line: 1002)

#3 0x00000000007e1c80 in pfree (pointer=<optimized out>) at mcxt.c:1002
#4 0x00000000006bdd24 in RemoveLocalLock (locallock=locallock(at)entry=0x3a90d68) at lock.c:1225
#5 0x00000000006c1ceb in LockReleaseAll (lockmethodid=lockmethodid(at)entry=1, allLocks=1 '\001') at lock.c:2083
#6 0x00000000006c3274 in ProcReleaseLocks (isCommit=isCommit(at)entry=0 '\000') at proc.c:752
#7 0x00000000007e3700 in ResourceOwnerReleaseInternal (owner=owner(at)entry=0x208b488, phase=phase(at)entry=RESOURCE_RELEASE_LOCKS,
isCommit=isCommit(at)entry=0 '\000', isTopLevel=isTopLevel(at)entry=1 '\001') at resowner.c:307
#8 0x00000000007e381f in ResourceOwnerRelease (owner=0x208b488, phase=phase(at)entry=RESOURCE_RELEASE_LOCKS,
isCommit=isCommit(at)entry=0 '\000', isTopLevel=isTopLevel(at)entry=1 '\001') at resowner.c:212
#9 0x00000000004e903b in AbortTransaction () at xact.c:2557
#10 0x00000000004e98ad in AbortCurrentTransaction () at xact.c:3003
#11 0x00000000006d45a3 in PostgresMain (argc=1, argv=0x202e638, dbname=0x202e610 "regression", username=0x202e5f0 "smith")
at postgres.c:3856
#12 0x0000000000466964 in BackendRun (port=0x204e080) at postmaster.c:4204
#13 BackendStartup (port=0x204e080) at postmaster.c:3880
#14 ServerLoop () at postmaster.c:1683
#15 0x000000000067867e in PostmasterMain (argc=argc(at)entry=3, argv=argv(at)entry=0x202d600) at postmaster.c:1292
#16 0x000000000046774d in main (argc=3, argv=0x202d600) at main.c:223

(gdb) p errordata[0]
$4 = {elevel = 20, output_to_server = 0 '\000', output_to_client = 1 '\001', show_funcname = 0 '\000', hide_stmt = 0 '\000',
hide_ctx = 0 '\000', filename = 0x9a1f80 "mcxt.c", lineno = 769, funcname = 0x9a24b0 <__func__.5880> "MemoryContextAlloc",
domain = 0x9350f6 "postgres-9.6", context_domain = 0x9350f6 "postgres-9.6", sqlerrcode = 8389,
message = 0x296d020 "out of memory", detail = 0x296cfe8 "Failed on request of size 128.", detail_log = 0x0, hint = 0x0,
context = 0x0, schema_name = 0x0, table_name = 0x0, column_name = 0x0, datatype_name = 0x0, constraint_name = 0x0, cursorpos = 0,
internalpos = 0, internalquery = 0x0, saved_errno = 12, assoc_context = 0x296a7a8}

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-09-20 20:12:53 Re: RemoveLocalLock pfree'ing NULL when out-of-memory
Previous Message Dean Rasheed 2015-09-20 16:53:07 Re: Inaccurate results from numeric ln(), log(), exp() and pow()