On Fri, Sep 05, 2003 at 02:40:50PM -0700, Michael Peppler wrote:
> One of the DBD::Sybase users is reporting that DBD::Sybase segfaults on
> startup when built with DBI 1.38, perl 5.8.0 with ithreads and 64 bit
> integers (but NOT 64 bit everything).
> 
> DBD::Sybase fails the first time it tries to access DBIS:
> 
> In dbd_init() we have:
> 
>     if(DBIS->debug >= 2) {
>         char *p = "";
>         if((sv = perl_get_sv("DBD::Sybase::VERSION", FALSE)))
>             p = SvPV(sv, lna);
> 
> and it segfaults on the if() statement.
> 
> If I'm not mistaken, this comes from the following:
>       # define DBIS (*(dbistate_t**)&SvIVX(DBISTATE_ADDRSV))
> which is used if MULTIPLICITY is defined (which it is when ithreads is
> enabled).
> 
> SvIVX will return a 64 bit entity in this situation, but pointers are 32 bit.
> 
> I have a feeling that there isn't any direct work-around, other than not
> using 64 bit integers?

Did it work for DBI-1.37 and/or before. Here's a patch to revert to DBI-1.37's
defintion:

--- DBIXS.h     Thu Aug 28 20:10:29 2003
+++ DIST/DBI-1.37/DBIXS.h       Tue May 13 14:54:19 2003
@@ -415,10 +415,12 @@
 # define DBISTATE_DECLARE typedef int dummy_dbistate /* keep semicolon from feeling 
lonely */
 # define DBISTATE_ASSIGN(st)
 # define DBISTATE_INIT
+static dbistate_t **get_dbistate() {
+    return ((dbistate_t**)&SvIVX(DBISTATE_ADDRSV));
+}
 # undef DBIS
-# define DBIS (*(INT2PTR(dbistate_t**, &SvIVX(DBISTATE_ADDRSV))))
-/* 'dbis' is temp for bad drivers using 'dbis' instead of 'DBIS' */
-# define dbis (*(INT2PTR(dbistate_t**, &SvIVX(DBISTATE_ADDRSV))))
+# define DBIS (*get_dbistate())
+# define dbis (*get_dbistate()) /* temp for bad drivers using 'dbis' instead of 
'DBIS' */

 #else  /* plain and simple non perl object / multiplicity case */

That may well not help but I'd be interested to know. If it doesn't
then some appropriate casting should work okay. I'm not sure when I'll
be able to dig into this so other volunteers are most welcome.

Tim.

Reply via email to