[Mono-bugs] [Bug 348751] New: System.IO.Ports.SerialPort.ReadExisting() throw NullReferenceException
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Fri Dec 14 09:56:10 EST 2007
https://bugzilla.novell.com/show_bug.cgi?id=348751
Summary: System.IO.Ports.SerialPort.ReadExisting() throw
NullReferenceException
Product: Mono: Class Libraries
Version: 1.2.5
Platform: x86
OS/Version: Windows XP
Status: NEW
Severity: Major
Priority: P5 - None
Component: System
AssignedTo: mono-bugs at ximian.com
ReportedBy: tom at opgenorth.net
QAContact: mono-bugs at ximian.com
Found By: ---
Description of Problem:
Calls to System.IO.PortsSerialPort.ReadExisting() seem to be consitently
throwing a NullReference exception when run under Mono 1.2.5+ and Win32. I
first found this in Mono 1.2.5 a couple of weeks ago, and decided to wait and
see if the issue would be fixed in Mono 1.2.6
Steps to reproduce the problem:
1. Execute the following code snippet:
2.
Actual Results:
NullReferenceException gets thrown. It seems that after about three such
calls, the runtime abends with only the following message. Note that this is
running mono --debug
Stacktrace:
This application has requested the Runtime to terminate in an unusual way.
Please contact the application's support team for more information.
Expected Results:
Should return a string, what was in the buffer (or possibly timeout).
How often does this happen?
Every time (on Windows).
Additional Information:
* Here is a snippet from my log file (log4net generated):
2007-12-14 07:34:11,843 [ 1] DEBUG
Opgenorth.Reloading.Chrony.Communications.SerialChronyPort [(null)]
System.NullReferenceException: Object reference not set to an instance of an
object
at (wrapper managed-to-native) System.IO.Ports.WinSerialStream:ClearCommError
(int,System.IO.Ports.CommStat&)
at System.IO.Ports.WinSerialStream.get_BytesToRead () [0x00000] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-1.2.6\mcs\class\System\System.IO.Ports\WinSerialStream.cs:396
at System.IO.Ports.SerialPort.get_BytesToRead () [0x00006] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-1.2.6\mcs\class\System\System.IO.Ports\SerialPort.cs:167
at System.IO.Ports.SerialPort.ReadExisting () [0x00006] in
C:\cygwin\tmp\monobuild\build\BUILD\mono-1.2.6\mcs\class\System\System.IO.Ports\SerialPort.cs:641
at (wrapper remoting-invoke-with-check)
System.IO.Ports.SerialPort:ReadExisting ()
at Opgenorth.Reloading.Chrony.Communications.SerialChronyPort.Open ()
[0x0007d] in
C:\Work\DotNet\Reloading.Root\src\app\Opgenorth.Reloading.Common\Chrony\Communications\SerialChronyPort.cs:133
Code Snippet:
* Note that _serialPort is a System.IO.Ports.SerialPort instance.
if (!_serialPort.IsOpen)
{
_serialPort.Open();
_serialPort.DiscardInBuffer();
_serialPort.DiscardOutBuffer();
SendCommand(InitCommand);
string openResult;
try
{
openResult = _serialPort.ReadExisting();
}
catch (NullReferenceException nre)
{
_log.Debug(nre);
openResult = string.Empty;
_log.DebugFormat("Assuming there is no Chrony on {0}.",
_serialPort.PortName);
_serialPort.Dispose();
}
catch (Exception)
{
_serialPort.Dispose();
throw new ConnectionFailedException(_serialPort.PortName);
}
if (!ReadyResponse.Equals(openResult,
StringComparison.Ordinal))
{
throw new ConnectionFailedException(_serialPort.PortName);
}
}
}
Here are the constants that _serialPort was configured with:
public const int BaudRate = 4800;
public const int DataBits = 8;
public const Parity ChronyParity = Parity.None;
public const StopBits ChronyStopBits = StopBits.One;
public const Handshake ChronyHandshake = Handshake.XOnXOff;
public const int ReadBufferSize = 2048;
public const int WriteBufferSize = 512;
public const int ReadTimeout = 2000;
public const int WriteTimeout = 2000;
public const bool RtsEnabled = true;
public const int CommandPause = 25;
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list