Re: Can a background worker exist without shared memory access for EXEC_BACKEND cases?

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Can a background worker exist without shared memory access for EXEC_BACKEND cases?
Date: 2020-08-05 13:02:40
Message-ID: CALj2ACXehv_QYWb+FmuiPbAa1MR_pT0BKKEq-FcQh1Soo-UM5Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 5, 2020 at 5:16 PM Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>
> On Wed, Aug 5, 2020 at 7:24 AM Bharath Rupireddy
> <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
> > In EXEC_BACKEND cases, right after PGSharedMemoryDetach(), the bg
> > worker will no longer be able to access the backend parameters, see
> > below(I tried this on my Ubuntu machine with a bgworker with no
> > BGWORKER_SHMEM_ACCESS flag and defined EXEC_BACKEND macro in
> > pg_config_manual.h) :
> >
> > (gdb) p *MyLatch
> > Cannot access memory at address 0x7fd60424a6b4
> > (gdb) p *ShmemVariableCache
> > Cannot access memory at address 0x7fd58427bf80
> > (gdb) p ProcStructLock
> > $10 = (slock_t *) 0x7fd60429bd00 <error: Cannot access memory at
> > address 0x7fd60429bd00>
> > (gdb) p *AuxiliaryProcs
> > Cannot access memory at address 0x7fd60424cc60
> > (gdb) p *ProcGlobal
> > Cannot access memory at address 0x7fd604232880
>
> Well all of those are pointers into the main shared memory segment,
> which is expected to be inaccessible after it is detached. Hopefully
> nobody should be surprised that if you don't specify
> BGWORKER_SHMEM_ACCESS, you can't access data stored in shared memory.
>

Right.

Will the proposed patch(v2) having some info in bgworker.sgml and
bgworker.h be ever useful to the users in some way?

With Regards,
Bharath Rupireddy.
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2020-08-05 13:14:36 Re: Can a background worker exist without shared memory access for EXEC_BACKEND cases?
Previous Message Amit Kapila 2020-08-05 12:55:20 Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions