Re: Bug #924: Segmentation fault in libpq/PQconsumeInput on

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: syatskevich(at)n21lab(dot)gosniias(dot)msk(dot)ru, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug #924: Segmentation fault in libpq/PQconsumeInput on
Date: 2003-05-26 17:53:02
Message-ID: 200305261753.h4QHr2K08613@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


I believe this will be fixed in the upcoming 7.3.3 release. Thanks for
the report.

---------------------------------------------------------------------------

pgsql-bugs(at)postgresql(dot)org wrote:
> Sergey N. Yatskevich (syatskevich(at)n21lab(dot)gosniias(dot)msk(dot)ru) reports a bug with a severity of 3
> The lower the number the more severe it is.
>
> Short Description
> Segmentation fault in libpq/PQconsumeInput on SSL connection
>
> Long Description
> When I start SSL connection and try to handle async query:
>
> // run query action handler
> void
> SqlDialog::sendQuery (const QString &_query) {
> PQsendQuery (m_conn, _query.utf8 ());
> connect(m_idle_timer, SIGNAL(timeout()), this, processQuery())
> }
>
> // run in idle loop
> void
> SqlDialog::processQuery () {
> // load data from server
> PQconsumeInput (conn);
>
> // if data not ready yet - return
> if (PQisBusy (conn))
> return;
>
> // process next query result when data completly loaded
> PQresult *res = PQgetResult (conn);
> if (res) {
> ...
>
> // wait next result
> return;
> }
>
> // all results handled
> disconnect(m_idle_timer, SIGNAL(timeout()), this, processQuery());
> }
>
> I get segmentation fault in PQconsumeInput. I run gdb
> and found that pqsecure_read recursive call itself infinite on
> SSL_ERROR_WANT_READ return code from libssl. I don't know why but
> this code don't work well for me and cause Stack Overflow
> (reported by OS (ALTLinux) as Segmentation Fault) error.
>
> I solve this problem easy: instead recirsive call pqsecure_read
> on SSL_ERROR_WANT_READ I simple return 0 as count of readed bytes.
> n = pqsecure_read (...)
> replace with
> n = 0;
> in pqsecure_read. I do that in pqsecure_write on SSL_ERROR_WANT_WRITE
> also.
>
> I check all places where pqsecure_* called and found that 0
> handled currectly at all.
>
> OS: ALTLinux - Sisyphus
> Kernel: Linux-2.4.20
> PostgreSQL: 7.3.2
> Qt: 3.0.5, 3.1.2
> libssl: 0.9.6i
>
>
> Sample Code
>
>
> No file was uploaded with this report
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2003-05-26 18:57:26 Re: Bug #926: if old postgresql.jar in CLASSPATH, ant fails
Previous Message Serge Obeuf 2003-05-26 14:35:46 Question to You