Re: plperl sigfpe reset can crash the server

From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Hannu Krosing <hannu(at)2ndquadrant(dot)com>
Subject: Re: plperl sigfpe reset can crash the server
Date: 2012-08-24 05:05:14
Message-ID: 201208240705.15183.andres@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Friday, August 24, 2012 06:55:04 AM Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)com> writes:
> > On Thursday, August 23, 2012 12:17:22 PM Andres Freund wrote:
> >> While debugging an instance of this bug I noticed that plperlu always
> >
> >> removes the SIGFPE handler and sets it to ignore:
> > In fact it can be used to crash the server:
> Um ... how exactly can that happen, if the signal is now ignored?

Don't ask me the hard questions at 7 in the morning. I have no clue yet.

I don't see where but something resets SIGFPE before the server crashes. If I
catch the sigfpe with gdb I see:

test=# SELECT pg_backend_pid();
pg_backend_pid
----------------
18084

root(at)awork2:/home/andres# grep -E '^Sig(Cgt|Ign)' /proc/18084/status
SigIgn: 0000000001301800
SigCgt: 0000000180006287

test=# SELECT (-2^31)::int/-1;
ERROR: floating-point exception
DETAIL: An invalid floating-point operation was signaled. This probably means
an out-of-range result or an invalid operation, such as division by zero.

root(at)awork2:/home/andres# grep -E '^Sig(Cgt|Ign)' /proc/18084/status
SigIgn: 0000000001301800
SigCgt: 0000000180006287

test=# DO LANGUAGE plperl $$$$;

root(at)awork2:/home/andres# grep -E '^Sig(Cgt|Ign)' /proc/18084/status
SigIgn: 0000000001301880
SigCgt: 0000000180006207

test=# SELECT (-2^31)::int/-1;

Program received signal SIGFPE, Arithmetic exception.
0x00007f858001f8c6 in int4div (fcinfo=0x7f8581b30320)

root(at)awork2:/home/andres# grep -E '^Sig(Cgt|Ign)' /proc/18084/status
SigIgn: 0000000001301800
SigCgt: 0000000180006207

Andres
--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2012-08-24 05:19:42 Re: plperl sigfpe reset can crash the server
Previous Message Tom Lane 2012-08-24 04:55:04 Re: plperl sigfpe reset can crash the server