Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Hackers > ecpg crash
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 9339 of 9770
Post > Topic >>

ecpg crash

by euler@[EMAIL PROTECTED] (Euler Taveira de Oliveira) May 10, 2008 at 12:14 AM

This is a multi-part message in MIME format.
--------------040201060404080209000207
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

While i'm working on a ecpg patch I found a bug in ecpg code. The simple 
program above could reproduce it. But basically it crashes (segfault) 
because it's trying to use a inexistent connection when we're preparing 
a statement. Don't know if it deserves a ecpg_log() message. A possible 
fix is attached.

#include <stdio.h>

exec sql whenever sqlerror sqlprint;

int main(void)
{
	exec sql begin declare section;
	char cmd[128];
	exec sql end declare section;

	exec sql connect to euler as main;
	sprintf(cmd, "select * from foo");
	exec sql prepare f from :cmd;
	exec sql disconnect;

	return 0;
}


(gdb) bt
#0  0xb7ebd9cd in find_prepared_statement (name=0x8048819 "f", con=0x0, 
prev_=0xbfccc6dc) at 
/a/pgsql/dev/pgsql/src/interfaces/ecpg/ecpglib/prepare.c:187
#1  0xb7ebd79f in ECPGprepare (lineno=15, connection_name=0x0, 
questionmarks=0, name=0x8048819 "f", variable=0xbfccc72c "select * from 
foo limit 1,2")
     at /a/pgsql/dev/pgsql/src/interfaces/ecpg/ecpglib/prepare.c:128
#2  0x0804865d in main ()


-- 
   Euler Taveira de Oliveira
   http://www.timbira.com/

--------------040201060404080209000207
Content-Type: text/x-patch;
 name="crash.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="crash.diff"

Index: src/interfaces/ecpg/ecpglib/prepare.c
===================================================================
RCS file:
/a/pgsql/dev/anoncvs/pgsql/src/interfaces/ecpg/ecpglib/prepare.c,v
retrieving revision 1.26
diff -c -r1.26 prepare.c
*** src/interfaces/ecpg/ecpglib/prepare.c	7 Feb 2008 11:09:13 -0000	1.26
--- src/interfaces/ecpg/ecpglib/prepare.c	10 May 2008 02:58:36 -0000
***************
*** 124,129 ****
--- 124,132 ----
  
  	con = ecpg_get_connection(connection_name);
  
+ 	if (!con)
+ 		return false;
+ 
  	/* check if we already have prepared this statement */
  	this = find_prepared_statement(name, con, &prev);
  	if (this && !deallocate_one(lineno, ECPG_COMPAT_PGSQL, con, prev,
this))

--------------040201060404080209000207
Content-Type: text/plain
Content-Disposition: inline
Content-Transfer-Encoding: 8bit
MIME-Version: 1.0


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@[EMAIL PROTECTED]
)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

--------------040201060404080209000207--
 




 3 Posts in Topic:
ecpg crash
euler@[EMAIL PROTECTED]   2008-05-10 00:14:57 
Re: ecpg crash
meskes@[EMAIL PROTECTED]   2008-05-10 11:03:58 
Re: ecpg crash
meskes@[EMAIL PROTECTED]   2008-05-12 18:32:31 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan13V112 Sun Jul 20 4:44:12 CDT 2008.