Odd program behaviour

From: James Thompson <jamest(at)math(dot)ksu(dot)edu>
To: PgSQL Interfaces <pgsql-interfaces(at)postgreSQL(dot)org>, pgsql-general(at)postgreSQL(dot)org, swig(at)cs(dot)utah(dot)edu
Subject: Odd program behaviour
Date: 1999-03-07 23:44:05
Message-ID: Pine.GSO.4.05.9903071657210.22421-100000@noether.math.ksu.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-interfaces


I'm desperate here. I've got two days invested in this and have not made
any progress at all. I'm hoping someone has run into the following and
might be able to give me a clue.

I have a a bunch of C functions that access the database via ecpg.
I have used SWIG to wrap these functions so that they may used in TCL/TK
I have the front end written in TCL/TK.

Everything works fine when saving data but pulling data from the database
results in a segfault when using the TCL/TK front end. The same functions
work fine when called from a C test program. In addition the
customer_create function listed in the backtrace is used alot in the front
end without problems. It only seems to bomb when I'm actively fetching
data from the database.

A backtrace on the core file gives me this.

#0 0x40248090 in ?? () from /lib/libc.so.6
#1 0x40247fa5 in ?? () from /lib/libc.so.6
#2 0x804ec5a in obmalloc (size=84) at memory.c:28
#3 0x804c896 in customer_create () at customer.ec:73
#4 0x8049ce2 in packet_create () at packet.ec:78
#5 0x804c475 in packet_query (object=0x80ecb60) at packet.ec:795
#6 0x80512c2 in _wrap_packet_query (clientData=0x0, interp=0x8058d~b8,
objc=2, objv=0x8059a48) at obe_wrap.c:1818
#7 0x400ca467 in ?? () from /usr/local/lib/libtcl.so

Now I'm fairly new to gdb but this looks like it's dying inside the
obmalloc which is simply...

obmalloc(size_t size)
{
void *tmp;

assert(size!=0);

tmp = malloc(size);
while (tmp == NULL) {
fprintf(stderr, "obmalloc: memory exhausted. 2 second delay before
retry");
sleep(2);
tmp = malloc(size);
}
return tmp;
}

I'm at the point that I can't think straight anymore. Does anyone have a
suggestion on why the code would work correctly from C but not TCL?

Oh, and if you wan't more info on what I'm trying to do visit

www.math.ksu.edu/~jamest/obe

I'd be willing to move the code up now if anyone wants to look at it.
I've mangled it up enough this weekedn it's probably good for a laugh.

Thanks in advance for any ideas you can provide.

->->->->->->->->->->->->->->->->->->---<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<
James Thompson 138 Cardwell Hall Manhattan, Ks 66506 785-532-0561
Kansas State University Department of Mathematics
->->->->->->->->->->->->->->->->->->---<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<-<

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Werges 1999-03-07 23:54:25 Bug?
Previous Message Albert Chen 1999-03-07 21:00:04 The *good* Chinese info regarding porting Postgres to NT

Browse pgsql-interfaces by date

  From Date Subject
Next Message Ken J. Wright 1999-03-08 03:00:29 outer joins
Previous Message Nitin Mule 1999-03-07 17:09:32 DBD::Pg ->Error in 'make test'