Re: margay fails assertion in stats/dsa/dsm code - Mailing list pgsql-hackers

From Robert Haas
Subject Re: margay fails assertion in stats/dsa/dsm code
Date
Msg-id CA+TgmobJ4bSLqxQmtc+8nEAZuwRtMNUdqaTX0ZEKPXi7XwF-fg@mail.gmail.com
Whole thread Raw
In response to Re: margay fails assertion in stats/dsa/dsm code  (Thomas Munro <thomas.munro@gmail.com>)
Responses Re: margay fails assertion in stats/dsa/dsm code
List pgsql-hackers
On Wed, Jun 29, 2022 at 12:01 AM Thomas Munro <thomas.munro@gmail.com> wrote:
> As for whether PostgreSQL needs to do anything, perhaps we should
> ereport for this unexpected error as a matter of self-preservation, to
> avoid the NULL dereference you'd presumably get on a non-cassert build
> with the current coding?  Maybe just:
>
> -               if (errno != EEXIST)
> +               if (op == DSM_OP_ATTACH || errno != EEXIST)
>                         ereport(elevel,
>                                         (errcode_for_dynamic_shared_memory(),
>                                          errmsg("could not open shared
> memory segment \"%s\": %m",
>
> margay would probably still fail until that underlying problem is
> addressed, but less mysteriously on our side at least.

That seems like a correct fix, but maybe we should also be checking
the return value of dsm_impl_op() e.g. define dsm_impl_op_error() as
an inline function that does if (!dsm_impl_op(..., ERROR)) elog(ERROR,
"the author of dsm.c is not as clever as he thinks he is").

-- 
Robert Haas
EDB: http://www.enterprisedb.com



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Hardening PostgreSQL via (optional) ban on local file system access
Next
From: Michel Pelletier
Date:
Subject: PATCH: Add Table Access Method option to pgbench