Subject: malloc, palloc question...

From: [email-masked]
Date: Wed, 27 Apr 1994 14:44:26 -0400 (EDT)

Hi:

I am using postgres version 4.1, lex, bison 1.21, and gcc 2.5.8

Problem:

When I do the following query "retrieve ( s.all, p.all )" inside
my code, I get a core dump.  If I do the query "retrieve ( s.all )"
everything works fine. Both classes s, and p are there.

Compilation is done as:

gcc -I/usr/postgres/include -L/usr/postgres/lib -lpq

Question:

The problem occurs in frame #0, which is in 
/usr/postgres/src/libpq/fe-pqstubs.c ( I greped for malloc in the
libpq directory and came up with this file name. )

If one is using the libpq.a library should one use palloc instead
of malloc ? Any suggestions or is the problem something else that
I may not have taken into account ?

-- Niranjan

Corefile:

[pollux] gdb sp
GDB is free software and you are welcome to distribute copies of it
under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.9, Copyright 1993 Free Software Foundation, Inc...
(gdb) b print.c:21
Breakpoint 1 at 0x8ccc: file print.c, line 21.
(gdb) r
Starting program: /home/staff/perera/project/sp 
Building list of user classes, attributes, and types...
SQL> select * from s, p ;
* retrieve (s.all, p.all) 

Breakpoint 1, PrintQuery (query=0x19968 "retrieve (s.all, p.all)")
    at print.c:21
21              response = (char *) PQexec(query);
(gdb) p response
$1 = 0x0
(gdb) p query
$2 = 0x19968 "retrieve (s.all, p.all)"
(gdb) s
Program received signal 11, Segmentation fault
0xef734634 in malloc ()
(gdb) where
#0  0xef734634 in malloc ()
#1  0xe68c in palloc ()
#2  0xd8d0 in pbuf_alloc ()
#3  0xda08 in pbuf_addValues ()
#4  0xec08 in dump_tuple ()
#5  0xf040 in dump_data ()
#6  0x976c in process_portal ()
#7  0xa5a4 in PQexec ()
#8  0x8cd8 in PrintQuery (query=0x19968 "retrieve (s.all, p.all)")
    at print.c:21
#9  0x49fc in yyparse () at gram.c:897
#10 0x7dc4 in main (argc=1, argv=0xeffff884) at main.c:47
(gdb) 

===============================================================================
    To add/remove yourself from the POSTGRES mailing list: send mail with 
    the subject line ADD or DEL to "[email-masked]"

    If this fails, send mail to "[email-masked]" and
    a human will deal with it.  DO NOT post to the "postgres" mailing list.
===============================================================================