Re: PQmakeEmptyPQresult makes my application dumps core? - Mailing list pgsql-bugs

From Gregory Stark
Subject Re: PQmakeEmptyPQresult makes my application dumps core?
Date
Msg-id 87zlyr9ohz.fsf@oxford.xeocode.com
Whole thread Raw
In response to PQmakeEmptyPQresult makes my application dumps core?  (Adam PAPAI <wooh@wooh.hu>)
List pgsql-bugs
"Adam PAPAI" <wooh@wooh.hu> writes:

>   PostgreSQL version:  (PostgreSQL) 7.4.7

Incidentally there have been 11 bug-fix releases to 7.4 since this one.
Several of those cause crashes or data corruption and you would be
well-advised to install 7.4.18 asap. Normally you don't need a dump/restore
but there were a couple bug-fix releases in that branch which might require
one depending on what locale you're using.

But that's not what's causing your problem I don't think:

> Usually our program dumps core several times a day, but the reason is unknown.
> All I know from the core file is the lines below.
>
> during PQexec(db->conn, query) it dumps core.
>
> Should it happen due to a connection problem between the pgsql server and our
> program? What could be the resolution to avoid the coredumps?
>
> (gdb) up
> #1  0xb7df4cff in malloc () from /lib/tls/libc.so.6
> (gdb) up
> #2  0xb7eed753 in PQmakeEmptyPGresult () from /usr/lib/libpq.so.3

This core dump is from the client, not the database server. That it's coming
from malloc makes me think it's likely you've done something wrong with your
memory allocations previously. Double-freeing a pointer, freeing a pointer
which didn't come from malloc, writing past the end or beginning of the
allocated memory, etc. Any bug like this can cause random core dumps in malloc
or free later.


--
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: PQmakeEmptyPQresult makes my application dumps core?
Next
From: "Evgeni"
Date:
Subject: BUG #3665: INSERT is not allowed in a non-volatile function