Thread: [BUGS] BUG #14902: valgrind - problem in PQconnectdb - pqSaveParameterStatusreported

[BUGS] BUG #14902: valgrind - problem in PQconnectdb - pqSaveParameterStatusreported

From
pavel.bazika@kocovnici.cz
Date:
The following bug has been logged on the website:

Bug reference:      14902
Logged by:          Pavel Bazika
Email address:      pavel.bazika@kocovnici.cz
PostgreSQL version: 10.1
Operating system:   Arch Linux
Description:

Hi,

I'm testing my application with helgrind threading error detection tool
(part of valgrind) and it reports a problem in libpq, when I'm calling
PQconnectdb from two threads:

==25830== Possible data race during write of size 4 at 0x7D600CC by thread
#1
==25830== Locks held: none
==25830==    at 0x7B2CFE4: pqSaveParameterStatus (fe-exec.c:1022)
==25830==    by 0x7B35A01: getParameterStatus (fe-protocol3.c:1378)
==25830==    by 0x7B36E77: pqParseInput3 (fe-protocol3.c:265)
==25830==    by 0x7B2DD7D: PQisBusy (fe-exec.c:1738)
==25830==    by 0x7B274D6: PQconnectPoll (fe-connect.c:2909)
==25830==    by 0x7B2829D: connectDBComplete.part.9 (fe-connect.c:1931)
==25830==    by 0x7B2B31F: connectDBComplete (fe-connect.c:589)
==25830==
==25830== This conflicts with a previous write of size 4 by thread #4
==25830== Locks held: none
==25830==    at 0x7B2CFE4: pqSaveParameterStatus (fe-exec.c:1022)
==25830==    by 0x7B35A01: getParameterStatus (fe-protocol3.c:1378)
==25830==    by 0x7B36E77: pqParseInput3 (fe-protocol3.c:265)
==25830==    by 0x7B2DD7D: PQisBusy (fe-exec.c:1738)
==25830==    by 0x7B274D6: PQconnectPoll (fe-connect.c:2909)
==25830==    by 0x7B2829D: connectDBComplete.part.9 (fe-connect.c:1931)
==25830==    by 0x7B2B31F: connectDBComplete (fe-connect.c:589)
==25830==    by 0x7B2B31F: PQconnectdb (fe-connect.c:590)

and

==25830== Possible data race during write of size 1 at 0x7D600C8 by thread
#1
==25830== Locks held: none
==25830==    at 0x7B2CFC3: pqSaveParameterStatus (fe-exec.c:1027)
==25830==    by 0x7B35A01: getParameterStatus (fe-protocol3.c:1378)
==25830==    by 0x7B36E77: pqParseInput3 (fe-protocol3.c:265)
==25830==    by 0x7B2DD7D: PQisBusy (fe-exec.c:1738)
==25830==    by 0x7B274D6: PQconnectPoll (fe-connect.c:2909)
==25830==    by 0x7B2829D: connectDBComplete.part.9 (fe-connect.c:1931)
==25830==    by 0x7B2B31F: connectDBComplete (fe-connect.c:589)
==25830==    by 0x7B2B31F: PQconnectdb (fe-connect.c:590)
==25830== 
==25830== This conflicts with a previous write of size 1 by thread #4
==25830== Locks held: none
==25830==    at 0x7B2CFC3: pqSaveParameterStatus (fe-exec.c:1027)
==25830==    by 0x7B35A01: getParameterStatus (fe-protocol3.c:1378)
==25830==    by 0x7B36E77: pqParseInput3 (fe-protocol3.c:265)
==25830==    by 0x7B2DD7D: PQisBusy (fe-exec.c:1738)
==25830==    by 0x7B274D6: PQconnectPoll (fe-connect.c:2909)
==25830==    by 0x7B2829D: connectDBComplete.part.9 (fe-connect.c:1931)
==25830==    by 0x7B2B31F: connectDBComplete (fe-connect.c:589)
==25830==    by 0x7B2B31F: PQconnectdb (fe-connect.c:590)

Is this false positive, bug or am I doing something wrong? The problem
occurrs when those static variables are written in fe-exex.c.

Thanks



--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

pavel.bazika@kocovnici.cz writes:
> I'm testing my application with helgrind threading error detection tool
> (part of valgrind) and it reports a problem in libpq, when I'm calling
> PQconnectdb from two threads:

It seems to be complaining about the assignments to static_client_encoding
and static_std_strings.  I wouldn't worry --- in the first place, those
assignments should be atomic writes (at least on most platforms) and
in the second place, the functionality involved is not guaranteed to
work in any program with more than one PGconn anyway.
        regards, tom lane