Skip to Content.
Sympa Menu

freetds - Re: [freetds] Help / 0.63 vs .82 error handling

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Thomas Stover <thomas AT wsinnovations.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: Re: [freetds] Help / 0.63 vs .82 error handling
  • Date: Wed, 09 Jul 2008 09:33:25 -0500

1) the escape sequence in the user name was a typo. When I posted the code, I took out my real user name and password, and also inadvertently one of the backslashes. That in and off itself does indeed cause a segfault. Although that wasn't my problem, thanks for your attention to detail.

2) The dbinit() in the wrong place is a glaring error, that I would have never caught. Thanks a bunch.

3) return codes - man! Its been so long since I looked at the docs for this stuff, somehow I had it in my head that many of these functions returned void and the only way to catch errors at all was with those callbacks. Even when I was testing this I was telling myself stuff like "why can't there just be a error codes". I'll check that out to.

4) 0.62 would call the callbacks in many situations even with the dbinit() in the wrong place for me. But that's ancient history now. 2008 here I come.
James K. Lowden Wrote:
You must call dbinit() before installing your handlers. The documentation
is very clear that dbinit() is to be called "before calling any other
DB-Library functions".
When I run your program verbatim (except that
DBSETLUSER(login, "domain\username") needs to be DBSETLUSER(login, "domain\\username")
because \u is an undefined escape in C) I get a segfault, as you do.
After moving dbinit() up four lines, I get this:

DB-Library Error 20109: NULL DBPROCESS pointer passed to DB-Library
sOperating System Error 0: Undefined error: 0

I get that message because dbopen() returned NULL, which was then passed
to dbcmd().
Your program "works" with 0.62 because the error handling and error
checking was primitive back in those days. In 0.82, every db-lib function
checks its inputs and emits appropriate error messages.
As you're not checking return codes, I think it's likely you're actually
just missing the errors. (I don't know the effect of installing handlers
before dbinit() in 0.62. I wouldn't be surprised if they just don't get
called.)
Thanks for posting. It's an interesting error, because on general
principles I believe it should be impossible to induce a segmentation
error using a library.
HTH.
--jkl






  • Re: [freetds] Help / 0.63 vs .82 error handling, Thomas Stover, 07/09/2008

Archive powered by MHonArc 2.6.24.

Top of Page