[Mono-bugs] [Bug 382635] New: submitting too long data for (n) varchar SqlParameter crashes mono

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Wed Apr 23 03:10:14 EDT 2008


           Summary: submitting too long data for (n)varchar SqlParameter
                    crashes mono
           Product: Mono: Class Libraries
           Version: 1.9.0
          Platform: i686
        OS/Version: Linux
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: Sys.Data
        AssignedTo: bnc-blr-team-mono at forge.provo.novell.com
        ReportedBy: josef.semmler at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---

Description of Problem:

If you have stored procedure with e.g. an nvarchar(50) parameter - and you want
to call this procedure with paramters you would do something like this:
param = new SqlParameter("@Name", SqlDbType.NVarChar, 50);
param.Value = myName;         //.Substring(0,50);
and then launch the stored procedure with this paramter.

If the length of "myName" is bigger than 50 you will end up with an exception
like this:

Unhandled Exception: Mono.Data.Tds.Protocol.TdsInternalException: Server closed
the connection. ---> System.IO.IOException: Write failure --->
System.Net.Sockets.SocketException: The socket has been shut down
  at System.Net.Sockets.Socket.Send (System.Byte[] buf, Int32 offset, Int32
size, SocketFlags flags) [0x00000]
  at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, Int32
offset, Int32 size) [0x00000] --- End of inner exception stack trace ---
  at System.Net.Sockets.NetworkStream.Write (System.Byte[] buffer, Int32
offset, Int32 size) [0x00000]
  at Mono.Data.Tds.Protocol.TdsComm.SendPhysicalPacket (Boolean isLastSegment)
  at Mono.Data.Tds.Protocol.TdsComm.SendPacket () [0x00000]
  at Mono.Data.Tds.Protocol.Tds.ExecuteQuery (System.String sql, Int32 timeout,
Boolean wantResults) [0x00000] --- End of inner exception stack trace ---
  at Mono.Data.Tds.Protocol.Tds.ExecuteQuery (System.String sql, Int32 timeout,
Boolean wantResults) [0x00000]
  at Mono.Data.Tds.Protocol.Tds70.Execute (System.String commandText,
Mono.Data.Tds.TdsMetaParameterCollection parameters, Int32 timeout, Boolean
wantResults) [0x00000]
  at Mono.Data.Tds.Protocol.Tds.Execute (System.String sql) [0x00000]

Steps to reproduce the problem:
You need a database (i use mssql). Create a stored procedure with a varchar(50)
paramter. The content of the SP does not matter. Write code to launch the SP -
pass the paramter with code like shown above.
An alternative way should be to try to insert data in a table with a
varchar(50) attribute.

Actual Results:
You get an exception (see above), the database connection is dropped,
application crashes. If you check the sqlserver logs, you will see a message
like "invalid buffer received - client unexpectedly closed connection".

Expected Results:
either a reasonable error message, which indicates the miss match in size - or
(preferred) the behaviour of microsoft .net ... .net seems to silently truncate
the parameter to the given size (in my case 50 chars)(which would result in
truncated data, without any notifications)

How often does this happen? 

Additional Information:
Defect was seen while trying to pass a parameter to a stored procedure.
What the correct behaviour would be, i'm not - but i would expect that mono
behaves as microsoft .net - as only this allows to run a .net application with
mono (in my case the application can not run with mono now).
The defect was seen with Mono 1.4, 1.6 and 1.9 - under linux (CentOs 4 and 5).
(Mono under windows was not tested)

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list