Re: introduce dynamic shared memory registry

From: Nathan Bossart <nathandbossart(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Abhijit Menon-Sen <ams(at)toroid(dot)org>, Michael Paquier <michael(at)paquier(dot)xyz>, Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: introduce dynamic shared memory registry
Date: 2024-01-21 22:13:20
Message-ID: 20240121221320.GA1682397@nathanxps13
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Jan 21, 2024 at 11:21:46AM -0500, Tom Lane wrote:
> Coverity complained about this:
>
> *** CID 1586660: Null pointer dereferences (NULL_RETURNS)
> /srv/coverity/git/pgsql-git/postgresql/src/backend/storage/ipc/dsm_registry.c: 185 in GetNamedDSMSegment()
> 179 }
> 180 else if (!dsm_find_mapping(entry->handle))
> 181 {
> 182 /* Attach to existing segment. */
> 183 dsm_segment *seg = dsm_attach(entry->handle);
> 184
>>>> CID 1586660: Null pointer dereferences (NULL_RETURNS)
>>>> Dereferencing a pointer that might be "NULL" "seg" when calling "dsm_pin_mapping".
> 185 dsm_pin_mapping(seg);
> 186 ret = dsm_segment_address(seg);
> 187 }
> 188 else
> 189 {
> 190 /* Return address of an already-attached segment. */
>
> I think it's right --- the comments for dsm_attach explicitly
> point out that a NULL return is possible. You need to handle
> that scenario in some way other than SIGSEGV.

Oops. I've attached an attempt at fixing this. I took the opportunity to
clean up the surrounding code a bit.

--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
v1-0001-fix-coverity-complaint.patch text/x-diff 1.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andy Fan 2024-01-21 23:26:04 Re: the s_lock_stuck on perform_spin_delay
Previous Message Pavel Luzanov 2024-01-21 21:34:58 Re: Things I don't like about \du's "Attributes" column