X-Original-To: pgsql-interfaces@postgresql.org Received: from main.gmane.org (main.gmane.org [80.91.224.249]) by postgresql.org (Postfix) with ESMTP id 7FB2B47634E for ; Thu, 13 Mar 2003 10:41:04 -0500 (EST) Received: from list by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 18tUn2-0000rh-00 for ; Thu, 13 Mar 2003 16:38:40 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-interfaces@postgresql.org Received: from news by main.gmane.org with local (Exim 3.35 #1 (Debian)) id 18tUka-0000hD-00 for ; Thu, 13 Mar 2003 16:36:08 +0100 From: Gerhard =?iso-8859-1?Q?H=E4ring?= Subject: Re: Seg fault on completing query Date: Thu, 13 Mar 2003 15:36:08 +0000 (UTC) Organization: OPUS GmbH Lines: 32 Message-ID: References: <3E70A394.9080802@liv.ac.uk> X-Complaints-To: usenet@main.gmane.org User-Agent: slrn/0.9.7.4 (CYGWIN_NT-5.0) X-Archive-Number: 200303/65 X-Sequence-Number: 3814 Chris Jewell wrote: > Hi, > > I'm working on a frontend to a Postgresql database. I've chosen C in > which to work, mainly because I wanted to learn the language. So, I'm > using the pqlib frontend library. The C source I have is below. I > compile it (on linux) with gcc -g -Wall -lpq -oantibug antibug.c. When > I run the executable, it prints out the query to the screen ok, but also > prints a "Segmentation Fault" on completion of the list. Does anyone > know why? This is really a C/Linux/gcc question. I haven't looked at your source, so just some general remarks: You'll want to compile your program with "-g" as an additional compiler switch. Then you also want core dumps to be written to disk "ulimit -c unlimited" in your shell. You can then analyze the core dump using gdb: $ gdb /path/to/your/app gdb> core /path/to/corefile # usually just 'core' gdb> bt # short for 'backtrace' You'll then see where your program crashed. Alternatively, run your app under gdb (or a GUI frontend like ddd/gvd/...) in the first place to see where it crashes. HTH, -- Gerhard