Re: Seg fault on completing query

From: Gerhard Häring <haering_postgresql(at)gmx(dot)de>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Seg fault on completing query
Date: 2003-03-13 15:36:08
Message-ID: slrnb719a6.1mc.gerhard.haering@haering.opus-gmbh.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Chris Jewell <vs0u8055(at)liv(dot)ac(dot)uk> 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

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Christof Petig 2003-03-13 15:40:25 Re: Roadmap for FE/BE protocol redesign
Previous Message cbbrowne 2003-03-13 15:35:43 Re: Roadmap for FE/BE protocol redesign