Re: Wierd omission in 4ge behaves in P-Code
Posted in 1997
Jonathan Leffler wrote: > > Jake, > > You know you should quote version numbers! Amazing! I actually forgot. It is 4GL 6.05, not quite ante-diluvian. > >From: Jacob Salomon <jake@apparel.net> > >Date: Tue, 5 Aug 1997 20:22:06 GMT > >X-Informix-List-Id: <news.41254> > > [...] > > >In my program, I do lots of formatting of data (for a Prodigy-plus > >label printer but that's not important). In one case, after > >formatting the data and inveigling the formatted data into an output > >string, the last character of the string vanishes. So I ran the > >program under the debugger. Nothing vanishes here. As P-Code? No > >problem. OK, desperate measures are in order. I peppered the > >relevant code with calls to errorlog() to display the data in > >progress. Suddenly it behaves again - that last character shows up > >again! I managed to isolate it down to one particular call - If I > >comment out this errorlog() call, the character vanishes from the > > output. If I leave it in, I get that last character. > [...] > > There were a couple of places, including errorlog(), where the I4GL > libraries would dump a stray ASCII NUL '\\0' into the middle of a > string, thus confusing the heck out of everybody and everything. As > far as I know, all of these were fixed by the 4.15/6.03 release. But > I suspect you're using one of the ante-diluvian versions such as 4.11. > Oh, and the p-code stuff sometimes using "pointer + length" for > processing data where the c-code stuff uses "pointer + search for > terminal '\\0'", which can lead to the discrepancy. Jonathan, that last point explains the reason for the discrepency. Errorlog() seemed to do something to the stack that caused a cleanup of the stack for the formatting call that followed it. The real reason for the problem was that the formatting function builds the formatted output using a local string variable (i.e. on the stack) and had neglected to initialize it to null before starting. In the P-Code, this is no problem. But in executable, the string started with whatever trash happened to be on the stack at the time. I cancelled the original posting about 10 minutes after I posted it, as soon as I realized it all my fault. I am re-posting this because I realize many folks *did* see the original post and might be curious for an answer. So here is a general rule: If a 4GL program behaves in P-Code but screws up in executable, then you have failed to initialize a local variable somewhere. -- -- Jake (In pursuit of undomesticated aquatic avians) +----------------------------------------------------------+ |Aside from that, how did you enjoy the play, Mrs. Lincoln?| +----------------------------------------------------------+