Re: pg_hba_file_settings view patch

From: Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>
To: Ashutosh Bapat <ashutosh(dot)bapat(at)enterprisedb(dot)com>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_hba_file_settings view patch
Date: 2017-01-09 00:45:55
Message-ID: CAJrrPGep=zHW3cpT0+Udz_e9zA-fCzwYsR9qaw9UtFjdeKAocA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Nov 29, 2016 at 9:15 PM, Ashutosh Bapat <
ashutosh(dot)bapat(at)enterprisedb(dot)com> wrote:

> Here's backtrace and some debugging information
> Program terminated with signal 11, Segmentation fault.
> #0 0x00000000007f96cd in shm_mq_sendv (mqh=0x121e998,
> iov=0x7ffc9b7b79f0, iovcnt=2, nowait=1 '\001') at shm_mq.c:357
> 357 Assert(mq->mq_sender == MyProc);
> (gdb) where
> #0 0x00000000007f96cd in shm_mq_sendv (mqh=0x121e998,
> iov=0x7ffc9b7b79f0, iovcnt=2, nowait=1 '\001') at shm_mq.c:357
> #1 0x00000000006d8387 in mq_putmessage (msgtype=88 'X', s=0x0, len=0)
> at pqmq.c:165
> #2 0x0000000000515147 in ParallelWorkerMain (main_arg=141900502) at
> parallel.c:1120
> #3 0x0000000000783063 in StartBackgroundWorker () at bgworker.c:726
> #4 0x0000000000795b77 in do_start_bgworker (rw=0x1216f00) at
> postmaster.c:5535
> #5 0x0000000000795e4f in maybe_start_bgworker () at postmaster.c:5710
> #6 0x0000000000794eb3 in sigusr1_handler (postgres_signal_arg=10) at
> postmaster.c:4959
> #7 <signal handler called>
> #8 0x00002b005933a693 in select () from /lib/x86_64-linux-gnu/libc.so.6
> #9 0x0000000000790720 in ServerLoop () at postmaster.c:1665
> #10 0x000000000078fe76 in PostmasterMain (argc=8, argv=0x11eef40) at
> postmaster.c:1309
> #11 0x00000000006d8f1d in main (argc=8, argv=0x11eef40) at main.c:228
> (gdb) p mq->mq_sender
> Cannot access memory at address 0x6b636568635f707d
> (gdb) p mq
> $1 = (shm_mq *) 0x6b636568635f706d
>

I found the reason to the crash. This is because of new discard_hba() call
that
is added in InitPostgres after authentication.

The PostmasterContext is deleted and set it to NULL for all children
processes
except normal backend process. But because of addition of discard_hba()
function
call in InitPostgres, the parsed_hba_context is checked for NULL and freed.
For
all other childrens except normal backend, this pointer is not NULL and it
leads to
freeing of some other memory and that leads to the crash of the parallel
worker.

The freeing of parsed_hba_context memory is required only for normal backend
processes after authentication, so moved the discard_hba() function call
into the
if block solved the problem.

But anyway the logic of reading hba rules is changed for pg_hba_rules view,
so
this patch is not required anyway. Just for reference I attached updated
patch.

Regards,
Hari Babu
Fujitsu Australia

Attachment Content-Type Size
discard_hba_and_ident_cxt_2.patch application/octet-stream 3.9 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2017-01-09 00:50:12 Re: PoC: Make it possible to disallow WHERE-less UPDATE and DELETE
Previous Message Jim Nasby 2017-01-09 00:27:42 Re: createdb warnings on OS X