Обсуждение: PQexec hangs, stuck on malloc_consolidate

Поиск
Список
Период
Сортировка

PQexec hangs, stuck on malloc_consolidate

От
Tor Gunston
Дата:
I have a C program using libpq.  After a successful connection to the
database over the network using PQsetdbLogin, the first call to PQexec
never returns.  top shows the process using 100% of CPU.

Here is my collection of clues:

1) My setup is Red Hat Linux 9.0, Postgresql version 7.4.0, installed
from binary RPMs.

2) The postmaster logs indicate that the query was received, and get as
far as "CommitTransactionCommand".

3) ethereal shows the query going out to the postmaster, and what looks
to me like a response coming back.

4) gdb backtrace shows the process stuck in malloc_consolidate:

#0  0x42074d44 in malloc_consolidate () from /lib/tls/libc.so.6
#1  0x420743c9 in _int_malloc () from /lib/tls/libc.so.6
#2  0x4207378d in malloc () from /lib/tls/libc.so.6
#3  0x408f8954 in pqResultAlloc () from /usr/lib/libpq.so.3
#4  0x409007fe in pqParseInput3 () from /usr/lib/libpq.so.3
#5  0x4090060f in pqParseInput3 () from /usr/lib/libpq.so.3
#6  0x408f9869 in PQconsumeInput () from /usr/lib/libpq.so.3
#7  0x408f99f1 in PQgetResult () from /usr/lib/libpq.so.3
#8  0x408f9cfb in PQexecPrepared () from /usr/lib/libpq.so.3
#9  0x0804aa38 in GetNextVal () at sql.c:106

5) The client and the postmaster are actually running on the same
machine.  If I switch from a network connection to a local connection
(using PQsetdb), everything works fine.

6) Any query I try (even "SELECT 1") produces the same result.

This seems like a bug in libpq to me, but since this is my first attempt
at using Postgresql, I'm going to assume that I'm the idiot and post it
here.

Thanks for any help in this matter.  I'll be happy to provide any
additional information, if it is needed.

--
Tor Gunston <tor@tor.to>


Re: PQexec hangs, stuck on malloc_consolidate

От
Tom Lane
Дата:
Tor Gunston <tor@tor.to> writes:
> 4) gdb backtrace shows the process stuck in malloc_consolidate:

> #0  0x42074d44 in malloc_consolidate () from /lib/tls/libc.so.6
> #1  0x420743c9 in _int_malloc () from /lib/tls/libc.so.6
> #2  0x4207378d in malloc () from /lib/tls/libc.so.6

This suggests to me that something has clobbered malloc's internal data
structures.  The most common cause of such an error is writing past the
end of a memory block obtained from malloc; other likely causes are
writing on already-freed memory, and ye ever-popular plain old wild store.

> This seems like a bug in libpq to me, but since this is my first attempt
> at using Postgresql, I'm going to assume that I'm the idiot and post it
> here.

I think it much more likely to be a bug in your surrounding program.
If you can provide a simple test case that reproduces the problem,
though, we can investigate the possibility of a bug in libpq.

            regards, tom lane

Re: PQexec hangs, stuck on malloc_consolidate

От
Tor Gunston
Дата:
You are correct.  It was my own fault.

Thanks for your time.

On Sun, 2004-01-11 at 15:42, Tom Lane wrote:
>
> This suggests to me that something has clobbered malloc's internal data
> structures.  The most common cause of such an error is writing past the
> end of a memory block obtained from malloc; other likely causes are
> writing on already-freed memory, and ye ever-popular plain old wild store.
>
>
> I think it much more likely to be a bug in your surrounding program.
> If you can provide a simple test case that reproduces the problem,
> though, we can investigate the possibility of a bug in libpq.

--
Tor Gunston <tor@tor.to>