Re: [ESQL/C] Segmentation Fault on Prepare
Posted in 1993
}From: johnd@leis.bellcore.com (John Droggitis) }Subject: [ESQL/C] Segmentation Fault on Prepare }Date: Wed, 20 Oct 1993 15:55:51 GMT }X-Informix-List-Id: <news.4669> } }This problem is driving me crazy! I'm getting a segmentation fault }on a prepare statement, for no apparent reason. Any help is greatly }appreciated. }The code: A vanilla prepare statement, illustrated below (simplified): } }sprintf(prep_str, "SELECT fld1, fld2 FROM %s ORDER BY fld1", from_clause); }$prepare p1 from prep_str; /* Statement that segfaults */ }$declare c1 cursor for p1; } . } }The above statements are parts of a subroutine that is linked to the }main routine that calls it. It will work for a certain number of times }(around 32) and then fail, always at the same iteration. Sounds like }a memory leak internal to esql/c. Do you ever use "$free c1;" or "$free p1;"? That may be part of the trouble. You'll need to check your ESQL/C manual (or maybe Guide to SQL Reference), but I think you need to release both c1 and d1 to be comfortable. }My debugger tells me that the prepare (that gets translated to an }_iqnprep() call in c) calls _iqlocate_cursor() which calls stcmpr() }which produces the segmentation fault. Umm. _iqlocate_cursor is intended to step through a linked list of cursors, checking for the one with the correct name. Are you sure that the rest of your program isn't trampling over some allocated memory, somehow? [I moved this line: JL] }Platform: Sun IPX, ESQL/C 4.10.UE1, informix online 5.01.UC1. That's odd -- 4.10 ESQL/C cannot generate _iqlocate_cursor() calls. The function wasn't introduced until 5.00. You aren't mixing and matching compiled ESQL/C code are you? And you're using a 5.01.UC1 ESQL/C, aren't you? Run esql -V to check. }I can certify that there's nothing wrong with the c variables that are }used in the prepare statement (prep_str and from_clause in the example }above). Can anyone offer some advice, other than calling informix tech }support? Why not call Informix Tech Support? Yours, Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>