Re: segmentation fault on Dynamic query using C

Lists: pgsql-bugs
From: Priyank Raj <tanha(dot)raj(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: segmentation fault on Dynamic query using C
Date: 2009-01-22 06:10:22
Message-ID: 1b493db80901212210g4286465ag42ff00a2a730641c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

I have a code(mention below), when i run this code on Intel machine it works
perfectly fine, but when i use AMD machine it giving me segmentation fault
at "EXEC SQL EXECUTE IMMEDIATE :qqq;" line. what could be the problem??

int main(int argc,char *argv[])
{

EXEC SQL BEGIN DECLARE SECTION;
const char *qqq = "insert into strands (id,filename,length,seq)
values(0,\'1\',2,\'{\"C\",\"A\"}\')";
char database[256],target[1024],host[256],user[256];
EXEC SQL END DECLARE SECTION;

exec sql whenever sqlerror sqlprint;

sprintf(target,"mydb(at)localhost");
ECPGdebug(1, stdout);

EXEC SQL CONNECT TO :target user priyank;

printf("1..\n");
EXEC SQL EXECUTE IMMEDIATE :qqq;
printf("2..\n");
EXEC SQL COMMIT;
printf("3..\n");

EXEC SQL DISCONNECT;
return 1;
}

i am using followinf command to make executable file

ecpg filename.pgc
gcc -Wall -o filename filename.o -lecpg -L/usr/local/pgsql/lib
-I/usr/local/pgsql/include -lcrypt

Thanks
Priyank Raj


From: Michael Meskes <meskes(at)postgresql(dot)org>
To: Priyank Raj <tanha(dot)raj(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: segmentation fault on Dynamic query using C
Date: 2009-01-22 11:08:54
Message-ID: 20090122110854.GB28630@feivel.credativ.lan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Thu, Jan 22, 2009 at 11:40:22AM +0530, Priyank Raj wrote:
> I have a code(mention below), when i run this code on Intel machine it works
> perfectly fine, but when i use AMD machine it giving me segmentation fault
> at "EXEC SQL EXECUTE IMMEDIATE :qqq;" line. what could be the problem??

Difficult to say without digging into it more. Could you run under gdb? Also to
reproduce this, could you please give us the exact table definition you use?
Otherwise we might guess wrong, which might have an impact.

Does it fail on ALL amd machines or just on one (hoping that you have more than
one to test)? Do you recompile on amd or use the same binary? This might be a
compiler optimization problem as well, could you try using different -O values
for gcc?

I can do some debugging as well, but have to either reproduce this on my system
or getting onto yours. :-)

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes(at)jabber(dot)org
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!