Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION
От
Andres Freund
Тема
Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION
Дата
Msg-id
20160225170311.qi3h6zbzf4mscdtj@alap3.anarazel.de
Ответ на
Список
Дерево обсуждения
BUG #13985: Segmentation fault on PREPARE TRANSACTION chris.tessels@inergy.nl
Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION Alvaro Herrera <alvherre@2ndquadrant.com>
Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION Andres Freund <andres@anarazel.de>
Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION "Shulgin, Oleksandr" <oleksandr.shulgin@zalando.de>
Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION Andres Freund <andres@anarazel.de>
Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION "Shulgin, Oleksandr" <oleksandr.shulgin@zalando.de>
Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION Tom Lane <tgl@sss.pgh.pa.us>
Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION Andres Freund <andres@anarazel.de>
Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION Tom Lane <tgl@sss.pgh.pa.us>
Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION Andres Freund <andres@anarazel.de>
Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION Tom Lane <tgl@sss.pgh.pa.us>
Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION "Shulgin, Oleksandr" <oleksandr.shulgin@zalando.de>
Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION Andres Freund <andres@anarazel.de>
Re: BUG #13985: Segmentation fault on PREPARE TRANSACTION Chris Tessels <chris.tessels@inergy.nl>
On 2016-02-25 09:51:49 -0500, Tom Lane wrote: > "Shulgin, Oleksandr" writes: > > On Wed, Feb 24, 2016 at 10:52 PM, Andres Freund wrote: > > At the very least ISTM that we have to make pgprocno volatile (or use a > >> memory barrier - but we don't have sufficient support for those in the > >> older branches), and move the PGPROC/PGXACT lookups after the == -1 > >> check. > > > Use of volatile doesn't change the resulting code dramatically for me. > > Marking pgprocno volatile is silly. What *is* missing is this: > > - ProcArrayStruct *arrayP = procArray; > + volatile ProcArrayStruct *arrayP = procArray; Well, that'll also force arrayP->numProcs to be loaded from memory every loop iteration. Not sure if we really want that. Otherwise, yes, that's pretty much what I'm suggesting, although I think a temporary volatile cast when loading pgprocno is better here. The important part is to force that pgprocno is loaded *once* *before* the checks. What bothers me about this right now is that we currently write the pgprocno array with: memmove(&arrayP->pgprocnos[index + 1], &arrayP->pgprocnos[index], (arrayP->numProcs - index) * sizeof(int)); arrayP->pgprocnos[index] = proc->pgprocno; arrayP->numProcs++; afaics there's absolutely no guarantee that memmov() will only use aligned sizeof(int) writes. Sure, efficiency reasons make that a sane choice, but a memmove() doing sizeof(char) wide moves would still be correct. Which afaics can mean we end up with completely bogus pgprocno values. Consider e.g. 0x0000ff00 being moved where previously 0x000000ff was set - we could temporarily end up with 0x0000ffff; which might be above MaxBackends. Regards, Andres
В списке pgsql-bugs по дате отправления
От: Andres Freund
Дата:
От: Andres Freund
Дата: