Re: BUG #7670: BUG #7545: Unresponsive server with error log reporting: "poll() failed: Invalid argument"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Igor <igorya(dot)inscriptio(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #7670: BUG #7545: Unresponsive server with error log reporting: "poll() failed: Invalid argument"
Date: 2012-11-18 19:19:07
Message-ID: 5168.1353266347@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> On 2012-11-18 14:07:37 -0500, Tom Lane wrote:
>> Anyway, even if Linux for some reason doesn't reject negative values,
>> I think we need to limit the GUC's range so we don't try to use them.
>> Maybe you'd get sane behavior and maybe you wouldn't. I notice that
>> the Single Unix Spec doesn't specify EINVAL for negative timeout
>> values, but it also doesn't define what happens for a negative value
>> other than -1. So this is basically an unspecified case and it's
>> incumbent on us to not do it if we want portable behavior.

> I aggree that we need to do something. I just think it might be enough
> to clamp the timeout value passed to WaitLatchOrSocket to the maximum
> valid value. The rest of SysLoggerMain seems to work correctly in that
> case.

This seems a rather 64-bit-centric view of the world. If "long" is
32 bits, the value will have overflowed before it ever gets to
WaitLatch.

I'm thinking it might be reasonable to put an Assert(timeout <= INT_MAX)
into WaitLatch, since we're already asserting timeout >= 0. But adding
a run-time clamp is not sufficient to fix the problem, because if any
overflow happens it's happening upstream.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Gavan Schneider 2012-11-18 23:32:12 Re: [BUGS] Prepared Statement Name Truncation
Previous Message Tom Lane 2012-11-18 19:15:16 Re: BUG #7670: BUG #7545: Unresponsive server with error log reporting: "poll() failed: Invalid argument"