From:             ben at thelemite dot freeserve dot co dot uk
Operating system: Solaris 10
PHP version:      5.2.0
PHP Bug Type:     MSSQL related
Bug description:  Crash when using 64-bit fields

Description:
------------
Executing SELECT * queries on tables that contain 64-bit values (such as
bigints) cause a seg fault.  Segfault occurs in
php_mssql_get_column_content_with_type within php_mssql.c

It's probably system dependent but has been verified on a separate Solaris
10 setup.

Note the following things though:

1) Running queries containing 64-bit fields that do not contain the
primary key do not seem to cause the crash, e.g: "SELECT value from
TestTable", but individually selecting fields does, e.g: "SELECT
id,value".  Bizzarely "SELECT value,id" doesn't cause a crash.

2) There seems to be some weird allocation issues going on that I have not
been able to get to the bottom of.  In
php_mssql_get_column_content_with_type there is:

case SQLFLT8:
        ZVAL_DOUBLE(result, (double) floatcol8(offset));
break; 

If I change it to:

case SQLFLT8:
{
        DBFLT8 res_buf;
        memcpy(&res_buf, &floatcol8(offset), 8);
        ZVAL_DOUBLE(result, res_buf);
}
break; 

It cures the problem!  But (very bizzarely), the following code still
crashes:

res_buf = *(DBFLT8 *)dbdata(mssql_ptr->link,offset);
ZVAL_DOUBLE(result, res_buf);


BUT... It does not crash at the point of reading the data into res_buf. 
It's crashes when something is done with the value!  (Possibly FreeTDS is
corrupting the stack?).

Help!


SunOS 5.10 Generic_118833-17 sun4u sparc SUNW,Ultra-60

PHP 5.1.6 (cli) (built: Oct 26 2006 15:30:54) [same on 5.2.0 as well
though]

FreeTDS 0.63




Reproduce code:
---------------
Table I have been using for experimenting:-

TestTable {
   id, int
   value, bigint
}

PHP code to generate crash:-

$link = mssql_connect("MyServer","MyUser","MyPassword");
$q = mssql_query("SELECT * from TestTable");
echo $q;

Expected result:
----------------
Resource id #X

Actual result:
--------------
nothing (segfaults when run from CLI)

-- 
Edit bug report at http://bugs.php.net/?id=39460&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=39460&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=39460&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=39460&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=39460&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=39460&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=39460&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=39460&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=39460&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=39460&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=39460&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=39460&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=39460&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=39460&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=39460&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=39460&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=39460&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=39460&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=39460&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=39460&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=39460&r=mysqlcfg

Reply via email to