Skip to Content.
Sympa Menu

freetds - Re: DBD::Sybase main.t crash

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Brian Bruns" <camber AT ais.org>
  • To: freetds
  • Subject: Re: DBD::Sybase main.t crash
  • Date: Sun, 29 Aug 1999 18:21:10



Ok, the server message is a red herring (it needs to be fixed but its not
causing this problem). The reason ct_describe() is failing is that its
getting called for column #5 (which doesn't exist) and the reason for that
is a bad cast in ct_res_info when requesting the number of columns (This is
a long standing bug that just happens to work on little endian
machine....copying 4 bytes when there are only 2 but the last two are zero,
so the integer still has the correct number. On big endian the zeros are
now the low order bytes and the number of columns returned is VERY large).
Anyway, this is fixed and checked in.

Except now we get a bus error. Which looks like an alignment problem. The
offending code is (in convert.c):

any.i = *((TDS_SMALLINT *) src);

where 'any' is a union of a bunch of types, 'i' is a 32 bit int and 'src'
is a 'unsigned char *'. When replaced by the following (endian specific)
code it works:

any.i = src[0]*256+src[1];

(long)src % 4 yields 1 so what DBD::Sybase passes really is unaligned.
*sigh*
So, it seems long ago I made a very bad assumption and now I've got to
replace all these casts with something else.

Well that may be a job for tommorow :)

BTW main.t does actually pass all tests on Solaris with the above hack.

Brian

On 08/26/99, "Michael Peppler <mpeppler AT peppler.org>" wrote:
> OK - now on Solaris 7, Sparc...
>
> I've made sure that HW_BIG_ENDIAN is defined.
>
> However, I get:
>
> kiruna (10:33AM):123 > perl -Mblib t/main.t
> Using /u6/home/mpeppler/src/Sybase-dist/DBD-Sybase-0.19/blib
> 1..12
> ok 1
> Switch: DBI-1.08 Switch by Tim Bunce, 1.08
> Available Drivers: ADO, ExampleP, Proxy, Sybase
> Unknown property 7
> ok 2
> ok 3
> ct_describe() failed at t/main.t line 61.
> 3805:
> Server message number=3805 severity=18 state=1 line=1 text=The token
> datastream length was not correct. This is an internal protocol error.
> not ok 4
> not ok 5
> zsh: segmentation fault (core dumped) perl -Mblib t/main.t
>
> I'll try to run the whole thing in the debugger, but there seems to be
> several problems here...
>
> I may spend some more time on this, but you may be interested in
> seeing this :-)
>
> Michael
>
> Michael Peppler writes:
> > Michael Peppler writes:
> > > Anyway - on linux I still core dump on the ct_connect(). The stack
> > > trace gives me:
> > >
> > > (gdb) bt
> > > #0 strncpy (s1=0x8192929 "", s2=0x0, n=30) at
> ../sysdeps/generic/strncpy.c:37
> > > #1 0x2abd9a21 in tds_set_server (tds_login=0x81928b0, server=0x0)
> > > at login.c:68
> > > #2 0x2abd5e27 in ct_connect (con=0x8127378, servername=0x81aabf8 "",
> > > snamelen=0) at ct.c:167
> > > #3 0x2abcbf1a in syb_db_connect ()
> > > #4 0x2abcb75f in syb_db_login ()
> > > #5 0x2abc89a9 in XS_DBD__Sybase__db__login ()
> > > #6 0x8087b7e in Perl_pp_entersub ()
> > > #7 0x80b162e in Perl_runops_standard ()
> > > #8 0x8058e01 in perl_call_sv ()
> > > #9 0x2abbea3c in XS_DBI_dispatch ()
> > > #10 0x8087b7e in Perl_pp_entersub ()
> > > #11 0x80b162e in Perl_runops_standard ()
> > > #12 0x8058791 in perl_run ()
> > > #13 0x8056bdb in main ()
> > >
> > > So there seems to be an invalid strcpy going on here - note that I'm
> > > not setting the server to anything, and expect the library to use the
> > > contents of $DSQUERY or, if that is empty, 'SYBASE'.
> > >
> > > I'll make a patch in a minute.
> >
> > OK - here's a patch:
> >
> > troll (10:08AM):378 > diff -c login.c.old login.c
> > *** login.c.old Thu Aug 26 10:08:12 1999
> > --- login.c Thu Aug 26 10:07:10 1999
> > ***************
> > *** 65,70 ****
> > --- 65,76 ----
> > }
> > void tds_set_server(TDSLOGIN *tds_login, char *server)
> > {
> > + if(!server || strlen(server) == 0) {
> > + server = getenv("DSQUERY");
> > + if(!server || strlen(server) == 0) {
> > + server = "SYBASE";
> > + }
> > + }
> > strncpy(tds_login->server_name, server,
> sizeof(tds_login->server_name));
> > }
> > void tds_set_library(TDSLOGIN *tds_login, char *library)
> >
> > This now runs on linux, apart from the "unknown property 7" message,
> > and of course that ?-style placeholders are not supported yet (aka
> > dynamic SQL.)
> >
> > Michael
> > --
> > Michael Peppler -||- Data Migrations Inc.
> > mpeppler AT peppler.org -||- http://www.mbay.net/~mpeppler
> > Int. Sybase User Group -||- http://www.isug.com
> > Sybase on Linux mailing list: ase-linux-list AT isug.com
> >
> > ---
> > You are currently subscribed to freetds as: mpeppler AT peppler.org
> > To unsubscribe, forward this message to $subst('Email.Unsub')
> >
>
> --
> Michael Peppler -||- Data Migrations Inc.
> mpeppler AT peppler.org -||- http://www.mbay.net/~mpeppler
> Int. Sybase User Group -||- http://www.isug.com
> Sybase on Linux mailing list: ase-linux-list AT isug.com




Archive powered by MHonArc 2.6.24.

Top of Page