From: Frank van Vugt <ftm.van.vugt@foxi.nl>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-interfaces@postgresql.org
Subject: SOLVED: Multi-threaded Qt app segfaults when using libpq with separate connections
Date: Fri, 8 Aug 2003 10:46:10 +0200
Message-ID: <200308081046.10157.ftm.van.vugt@foxi.nl> (raw)
In-Reply-To: <13531.1060036862@sss.pgh.pa.us>
References: <200308041729.13212.ftm.van.vugt@foxi.nl>
<200308050034.20405.ftm.van.vugt@foxi.nl>
<13531.1060036862@sss.pgh.pa.us>
Hi,
I *finally* nailed this thing, turns out NOT to be a PG problem, more like
PEBKC.
Tom Lane wrote:
> I get the impression that something is clobbering memory with abandon.
He was write (duh..).
What wasn't clear (at least to me) from the Qt-docs is that a name given to a
supplementary database connection must be unique, otherwise the new one will
replace the old one. Expecting to be able to handle the connections by the
pointers an addDatabase() call returned, I had been creating new connections
in separate threads whose names weren't always unique.
Since 'connection' here implicates a PGconn structure, I had been 'switching'
PGconn structures while in use. It seems one can even get away with that for
a limited number of threads, but at a certain point newly created result
structures (PGresult, PQntubles, PQnfields, etc.) will be allocated space on
top of the older structures belonging the replaced connections, which is
obviously the point where things get very messy....
I've asked the Trolls (Qt) to emphasize this potential problem in their docs.
Thanks to Tom Lane (PostgreSQL) and Harald Fernengel (TrollTech) for their
pointers ;)
Best,
Frank van Vugt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: ftm.van.vugt@foxi.nl, tgl@sss.pgh.pa.us
Subject: Re: SOLVED: Multi-threaded Qt app segfaults when using libpq with separate connections
In-Reply-To: <200308081046.10157.ftm.van.vugt@foxi.nl>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox