Subject: Tracking Down User Traps
To: None <port-alpha@netbsd.org>
From: Thomas T. Thai <tom@minnesota.com>
List: port-alpha
Date: 12/31/2000 01:04:00
i've got CVS version of PostgreSQL down to 2 regression test failures. i'd
like to get rid of these two tests. however, i'm not experienced enough
to track down these last two bugs. the problem is any query that cause
errors like the ones listed below will cause user traps from the kernel.

---<cut>---
regression=# INSERT INTO TIMESTAMP_TBL VALUES ('invalid');
ERROR:  floating point exception! The last floating point operation either
exceeded legal rangesor was a divide by zero

regression=# INSERT INTO TIMESTAMP_TBL VALUES ('Invalid Abstime');
ERROR:  floating point exception! The last floating point operation either
exceeded legal ranges or was a divide by zero

regression=#  SELECT '' AS three, f1 as abstime, timestamp(f1) AS
timestamp
    FROM ABSTIMregression-# E_TBL WHERE NOT isfinite(f1);
ERROR:  floating point exception! The last floating point operation either
exceeded legal ranges or was a divide by zero
---</cut>---

so it seems that anything that caused a "floating point exception" would
cause:

---<cut>---
Dec 31 00:41:03 ns01 /netbsd: fatal user trap:
Dec 31 00:41:03 ns01 /netbsd:
Dec 31 00:41:03 ns01 /netbsd:     trap entry = 0x1 (arithmetic trap)
Dec 31 00:41:03 ns01 /netbsd:     a0         = 0x3
Dec 31 00:41:03 ns01 /netbsd:     a1         = 0x1000000000000
Dec 31 00:41:03 ns01 /netbsd:     a2         = 0x1203f9880
Dec 31 00:41:03 ns01 /netbsd:     pc         = 0x12013ad60
Dec 31 00:41:03 ns01 /netbsd:     ra         = 0x1200ac15c
Dec 31 00:41:03 ns01 /netbsd:     curproc    = 0xfffffc0023bb7418
Dec 31 00:41:03 ns01 /netbsd:         pid = 14283, comm = postgres
Dec 31 00:41:03 ns01 /netbsd:
---</cut>---


here are gdb outputs:

---<cut>---
Program received signal SIGFPE, Arithmetic exception.
abstime_timestamp (fcinfo=0x1203f97e0) at nabstime.c:641
641                             break;
(gdb) bt
#0  abstime_timestamp (fcinfo=0x1203f97e0) at nabstime.c:641
#1  0x1200ac15c in ExecMakeFunctionResult (fcache=0x1203f97c0,
    arguments=0x1203f8200, econtext=0x1203f9230, isNull=0x1ffffe9d8 "",
    isDone=0x1ffffe8e0) at execQual.c:789
#2  0x1200ac314 in ExecEvalFunc (funcClause=0x1203f97e0,
econtext=0x1203f9230,
    isNull=0x1ffffe9d8 "", isDone=0x1ffffe8e0) at execQual.c:883
#3  0x1200aca10 in ExecEvalExpr (expression=0x1203f97e0,
econtext=0x1203f9880,
    isNull=0x10000 <Error reading address 0x10000: Invalid argument>,
    isDone=0x1203f9880) at execQual.c:1208
#4  0x1200ace48 in ExecTargetList (targetlist=0x1203f80e0,
nodomains=-5920,
    targettype=0x1203f93d0, values=0x1203f9630, econtext=0x1203f9230,
    isDone=0x1ffffea68) at execQual.c:1528
#5  0x1200ad13c in ExecProject (projInfo=0x160a427c0, isDone=0x1)
    at execQual.c:1751
#6  0x1200ad290 in ExecScan (node=0x1203f8af0, accessMtd=0x1200b61e0
<SeqNext>)
    at execScan.c:139
#7  0x1200b635c in ExecSeqScan (node=0x1203f97e0) at nodeSeqscan.c:138
#8  0x1200aa8ac in ExecProcNode (node=0x1203f8af0, parent=0x1203f8af0)
    at execProcnode.c:284
#9  0x1200a917c in ExecutePlan (estate=0x1203f8c30, plan=0x1203f8af0,
    operation=CMD_SELECT, numberTuples=0, direction=-5920,
    destfunc=0x1203f9770) at execMain.c:959
#10 0x1200a8020 in ExecutorRun (queryDesc=0x1203f97e0, estate=0x1203f8c30,
---Type <return> to continue, or q <return> to quit---
    feature=3, count=0) at execMain.c:233
#11 0x12011af78 in ProcessQuery (parsetree=0x1203f8c30, plan=0x1203f8c00,
    dest=Remote) at pquery.c:305
#12 0x120118fb0 in pg_exec_query_string (
    query_string=0x1203f4050 " SELECT '' AS three, f1 as abstime,
timestamp(f1)
AS timestamp\n    FROM ABSTIME_TBL WHERE NOT isfinite(f1);", dest=Remote,
    parse_context=0x120366390) at postgres.c:817
#13 0x12011a748 in PostgresMain (argc=4, argv=0x1202cf238, real_argc=3,
    real_argv=0x1fffff8b0, username=0x12035a275 "pgsql") at
postgres.c:1827
#14 0x1200f831c in DoBackend (port=0x12035a000) at postmaster.c:2027
#15 0x1200f7ca8 in BackendStartup (port=0x12035a000) at postmaster.c:1804
#16 0x1200f6818 in ServerLoop () at postmaster.c:959
#17 0x1200f5ff0 in PostmasterMain (argc=3, argv=0x1fffff8b0)
    at postmaster.c:666
#18 0x1200c34c0 in main (argc=3, argv=0x1fffff8b0) at main.c:143
(gdb) c
Continuing.
---</cut>---

can someone help me find out which function from what file is causing
this?