[freetds] 0.63 Release Candidate 7

Lowden, James K LowdenJK at bernstein.com
Fri Jan 7 11:06:41 EST 2005


> > "James K. Lowden" <jklowden at schemamania.org> wrote:
> > src/dblib/unittests/rpc is broken in RC6 and HEAD.  I think it might
> be
> > the test; I'm not sure if it's valid to fetch the parameter's name
> after
> > dbresults() returns no more results.  In any case, when we get to
> > 
> > 	fprintf(stdout, "'%s' instead.\n", retname);
> > 
> > retname points to outer space.  
> 
> I really don't understand. I looked at your change and I don't
> understand what should be changed... Yesterday I tought that problem
was
> using mssql (I had only a Sybase server to test) but today I tested
with
> mssql2k (newer and former test version) and I don't notice any
> problem...

	while dbresults() {
		while dbnextrow() [
		}
		if dbnumrets() {
			name =	dbretname()
		}
	}
	puts(name);

Question: what is the lifetime of the memory pointed to by the return
value of dbretname()?  Can it be expected to remain unfreed after
dbresults() returns NO_MORE_RESULTS?  I think the answer is no.  

I know the unit test segfaulted on fprintf() trying to derereference
retname.  I didn't check rcp.c to see whether the pointer had been
freed.  Depending on your machine, of course, dereferencing a freed
value might or might not cause a problem.  

If you think I'm misreading the docs, or you know that a vendor's
implementation (consistently) allows the above, then we ensure
dbretname()'s return buffer isn't freed until it's reused.  If it turns
out it's not being freed, then I guess I'll have to look into what's
happening on my box.  

BTW, I was confused for a bit, I think by libtool.  The unit test
executables have moved, and unless you've done a "make clean" lately,
you might be picking up the old ones:

$ file $(find build/src/dblib/ -name rpc) | cut -b-63
build/src/dblib//unittests/.libs/rpc: ELF 32-bit LSB executable
build/src/dblib//unittests/rpc:       ELF 32-bit LSB executable

$ ls -ghn $(find build/src/dblib/ -name rpc)
-rwxr-xr-x  1 100   33K Mar 25  2004
build/src/dblib//unittests/.libs/rpc
-rwxr-xr-x  1 100   45K Jan  5 13:38 build/src/dblib//unittests/rpc

It used to be that unittests/.libs/rpc was the binary and unittests/rpc
was a script that called the binary.  Nowadays the .lib directory isn't
even created.  

--jkl

-----------------------------------------
The information contained in this transmission may contain privileged and confidential information and is intended only for the use of the person(s) named above. If you are not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, any review, dissemination, distribution or duplication of this communication is strictly prohibited. If you are not the intended recipient, please contact the sender immediately by reply e-mail and destroy all copies of the original message. Please note that we do not accept account orders and/or instructions by e-mail, and therefore will not be responsible for carrying out such orders and/or instructions.
If you, as the intended recipient of this message, the purpose of which is to inform and update our clients, prospects and consultants of developments relating to our services and products, would not like to receive further e-mail correspondence from the sender, please "reply" to the sender indicating your wishes.  In the U.S.: 1345 Avenue of the Americas, New York, NY 10105.




More information about the FreeTDS mailing list