[freetds] Problems with large image transfers.

Lowden, James K LowdenJK at bernstein.com
Tue Sep 21 15:35:13 EDT 2004

----Original Message-----
From: David Lambert
Sent: Tuesday, September 21, 2004 11:56 AM

As requested, here is the backtrace:

Program received signal SIGSEGV, Segmentation fault.
0x00c189e2 in fwrite () from /lib/tls/libc.so.6
(gdb) backtrace
#0  0x00c189e2 in fwrite () from /lib/tls/libc.so.6
#1  0x08054d47 in _bcp_exec_out (dbproc=0x8f7a218,
    at bcp.c:785
#2  0x08056732 in bcp_exec (dbproc=0x8f7a218, rows_copied=0xfef2c784)
    at bcp.c:1624
#3  0x0804ab92 in file_character (pdata=0xfef2c7b0, dbproc=0x8f7a218,
    at freebcp.c:592
#4  0x0804982e in main (argc=13, argv=0xfef2f8e4) at freebcp.c:93

Oh, boy.  You found a doozie.  

It's interesting that I assumed you meant bcp *in*.  I've uploaded image
data, but never downloaded it.  Neither, I bet, has anyone else, because
it looks to me like the code's broken.  

_bcp_exec_out sets buflen and destlen to 255 by default, and has no
special case for image/text data.  Allocation is done when
tds_process_row_tokens() eventually calls tds_get_data(), which sets
curcol->column_cur_size.  _bcp_exec_out() assigns that to srclen, and
calls dbconvert(), which should return -1 ("Data-conversion resulted in
overflow"), because the destination buffer hasn't been reallocated.  And
line 785 shouldn't be executed, because buflen is less than zero.  

Anyway, I don't see how it can work, because the destination buffer
isn't allocated AFAICT.  

This will take some work, and it may be a few weeks before I can get to
it, thanks to the phone company.  If you want to trace through more
carefully, find out what dbconvert() is called with, returns, and what
fwrite is being called with, I might be able to suggest a patch.  



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.
If you, as the intended recipient of this message, the purpose of which is to inform and update our clients, prospects and consultants of developments relating to our services and products, would not like to receive further e-mail correspondence from the sender, please "reply" to the sender indicating your wishes.  In the U.S.: 1345 Avenue of the Americas, New York, NY 10105.

More information about the FreeTDS mailing list