Re: memory leak (well, kind of...) ?
Posted in 1993
>From: uunet!tglobe2.tollpost.no!ogj (Oyvind Gjerstad) >Subject: Re: memory leak (well, kind of...) ? >Date: 11 May 93 11:44:43 GMT >X-Informix-List-Id: <news.3278> >>>We have a program written in ESQL/C from Informix that is running as >>>a daemon. Lately that program has died occasionally. When it dies, it >>>writes an message to the terminal that started it: >>>> 4GL run-time error number -4518. The 4GL program cannot >>>> allocate any more space for temporary string storage. >>>Have anybody experienced this message from ESQL/C ? What language >>>constructs are likely to be the culprit ? >>Sorry, but this *must* be a 4GL program. A pure ESQL/C program simply >>cannot generate a -4518. >We have tracked down the problem, and it *is* an ESQL/C-program. The >problem was that we have functions in our libraries that are used from >both 4GL and C. The return from these functions must differ depending >on whether they are called from C or 4GL. In this case we had a >function that did a retquote() everytime it returned. This apparently >filles TSS with return values. Why on earth would a sane ESQL/C programmer use a function which is only required to allow you to communicate with I4GL in an ESQL/C (and not I4GL) program. Someone has seriously misread the manual (or misunderstood it), to even think of doing that! >This very simple esql/c program demonstrates this: >main() { for(;;) retquote("foo"); } Here's a simple program that eventually crashes on most machines: #include <string.h> #include <stdlib.h> int main() { void *v = 0; long l = 0; while (l > 0) { v = realloc(v, l += 1024); strcpy(v, "Abyssinia"); } return(0); } Just because it can be written doesn't make it sensible. Ooops! I'm in danger of being controversial again. Sorry. Jonathan Leffler (johnl@obelix.informix.com) #include <disclaimer.h>