[freetds] Segmentation fault retrieving non-NULL datetime fields

James K. Lowden jklowden at freetds.org
Sat Nov 5 10:55:23 EST 2005

Robert Benjamin wrote:
> I am using freetds 0.63 with php 4.4.1. I have a simple script which 
> executes the query
> "SELECT [DateModified] FROM PEOPLE WHERE LastName LIKE '%Smith%'
> When fetching the data with the code
> while ($row = $rs->fetchRow(DB_FETCHMODE_ASSOC))
> {
>    print "Date modified is " . $row["DateModified"] . "\n" ;
> }
> if the DateModified is _not_ NULL, I get a segmentation fault. 

The form of the default datetime->character conversion has been carefully
set to mimic that of the vendors' libraries. I think if you get a
backtrace in gdb for your simple script, you'll find the culprit is
somewhere in the PHP code.  

FreeTDS transports your datetime field in its native format, and PHP
converts it to a character string.  The conversion may be implicit
(dbbind) or explicit (dbconvert); I don't know.  Regardless, it's
certainly an opportunity to fail to allocate enough memory for the
conversion, which is certainly one route to a segmentation fault.  




More information about the FreeTDS mailing list