[freetds] Help / 0.63 vs .82 error handling
thomas at wsinnovations.com
Wed Jul 9 10:33:25 EDT 2008
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
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
> 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.
More information about the FreeTDS