Skip site navigation (1) Skip section navigation (2)

(stupid) bug in agg_select_candidate

From: David Sauer <davids(at)iol(dot)cz>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: (stupid) bug in agg_select_candidate
Date: 1998-12-23 00:05:23
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers

  I'm trying postgres 6.4.1 and I have problem with select command:

> create table t( text_column text );
> select sum( text_column ) from t;
This command makes no sense, but causes crash in backend:

pqReadData() -- backend closed the channel unexpectedly.
        This probably means the backend terminated abnormally before or while processing the request.
We have lost the connection to the backend, so further processing is impossible.  Terminating.

See backtrace:

(gdb) bt
#0  agg_select_candidate (typeid=25, candidates=0x81e7838) at
#1  0x80bd5be in ParseFuncOrColumn (pstate=0x81ded30,
    funcname=0x81deb40 "sum", fargs=0x81deba0, curr_resno=0x81ded30,
    precedence=1) at parse_func.c:391
#2  0x80bc7b9 in transformExpr (pstate=0x81ded30, expr=0x81debc0,
    at parse_expr.c:267
#3  0x80c12fa in MakeTargetEntryComplex (pstate=0x81ded30, res=0x81debe0)
    at parse_target.c:363
#4  0x80c1754 in transformTargetList (pstate=0x81ded30,
    at parse_target.c:569
#5  0x80b45f1 in transformSelectStmt (pstate=0x81ded30, stmt=0x81deca0)
    at analyze.c:912
#6  0x80b382d in transformStmt (pstate=0x81ded30, parseTree=0x81deca0)
    at analyze.c:200
... more ....

Problem is in function 'agg_select_candidate' itself, simple debugging
session follows: (comment starts with '!')

Reading symbols from /lib/
Reading symbols from /lib/
Reading symbols from /lib/
Reading symbols from /usr/lib/
Reading symbols from /usr/lib/
Reading symbols from /lib/
Reading symbols from /usr/lib/
Reading symbols from /lib/
Reading symbols from /lib/
0x401356f4 in __read ()
(gdb) break agg_select_candidate Quit
(gdb) break agg_select_candidate
Breakpoint 1 at 0x80bd2f9: file parse_func.c, line 198.
(gdb) cont

Breakpoint 1, agg_select_candidate (typeid=25, candidates=0x81e7838)
    at parse_func.c:198
198             category = TypeCategory(typeid);
(gdb) next
199             ncandidates = 0;
200             last_candidate = NULL;

!!!!! setting to NULL (0)

201             for (current_candidate = candidates;
(gdb) print last_candidate
$1 = (struct _CandidateList *) 0x0
(gdb) next
202                      current_candidate != NULL;
205                     current_typeid = current_candidate->args[0];
206                     current_category = TypeCategory(current_typeid);
208                     if ((current_category == category)

!!!!! condidion isn't true

(gdb) print current_category
(gdb) print category
(gdb) next
230                             last_candidate->next = NULL;

!!!! NULL is dereferenced ... this will crash backend

(gdb) next

Program received signal SIGSEGV, Segmentation fault.
agg_select_candidate (typeid=25, candidates=0x81e7838) at parse_func.c:230
  Machine is x86, compiled with egcs-1.1.1.

			thanks for any fix and happy Xmas,

* David Sauer, student of Czech Technical University
* electronic mail: davids(at)iol(dot)cz (mime compatible)


pgsql-hackers by date

Next:From: Thomas G. LockhartDate: 1998-12-23 01:54:24
Subject: Re: [HACKERS] Problems on NUMERIC
Previous:From: The Hermit HackerDate: 1998-12-22 18:50:58
Subject: Re: [HACKERS] ecpg patches

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group