[freetds] Found Segmentation fault causes
Lowden, James K
LowdenJK at bernstein.com
Tue May 6 13:04:08 EDT 2003
> From: Aliet Santiesteban Sifontes [mailto:alietss at yahoo.com]
> Sent: May 6, 2003 12:07 PM
> I have found the segmentation fault with httpd-2.0.45
> php-4.3.2 freetds-0.62-dev on RedHat 9.0 TDS 7.0
> against a Microsoft SQL Server 2000, the problem is
> when some of the queries field is of type datetime
> httpd: read.c:365: tds_get_char_data: Assertion
> `in_left < 4' failed.
Probably you should just wait. I'm going to modify tds_get_char_data()
(where your assert is stumbling) according to Frediano's suggestion, and
tds_iconv() will look more like iconv(3) with the added ability to emit
client-side error messages. I would be very pleased if you'd try my next
version as soon as it's ready.
What is the assert for?
tds_get_char_data() reads from the wire in 256-byte chunks, passing them to
tds_iconv() for conversion. It makes no attempt to ensure the input buffer
is character-aligned: the tail end of those 256 bytes might include a
partial character. (That wouldn't happen in your case, because your server
uses two-byte characters, but it would be possible of the server were
UTF-8.) The largest partial character would be 3 bytes long, so when
tds_iconv() is done, absent a logic error, there shouldn't be more than
three unconverted bytes left over in the input buffer. Hence the assertion
that `in_left < 4'.
Unfortunately, logic errors are not absent. The output buffer might not be
big enough (can't tell, not logged). And tds_iconv() exits prematurely if
it encounters an error other than EILSEQ, again without logging it.
I'd send you a patch, but since I'm going to redo those functions, there's
no point in acquiring further diagnostics.
If you're really in a jam, you could try removing the assert (read.c:365,
like it says), and removing these lines from the while loop in
if (errno != EILSEQ)
You will probably get partial data, so please don't try this except as an
The information contained in this transmission may contain privileged and
confidential information and is intended only for the use of the person(s)
named above. If you are not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, any
review, dissemination, distribution or duplication of this communication is
strictly prohibited. If you are not the intended recipient, please contact
the sender immediately by reply e-mail and destroy all copies of the
original message. Please note that we do not accept account orders and/or
instructions by e-mail, and therefore will not be responsible for carrying
out such orders and/or instructions.
More information about the FreeTDS