By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,467 Members | 1,553 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,467 IT Pros & Developers. It's quick & easy.

Unusual C# errors (Maybe memory corruption)

P: n/a
I have written a multi-threaded c# windows service in .net 1.1 (Visual
Studio .net 2003). The service has several threads that poll a Sql 6.5
database on another machine. Each thread will execute a stored
procedure, and the results are used to determine if there is anything
for this particular thread to do. My problem is that I periodically
get exceptions from places that normally shouldn't get exceptions. The
service can run find for hours (10+). Then sometimes it will having a
null reference exceptions and the service crashes and restarts.

Most exceptions are of the type:
System.NullReferenceException: Object reference not set to an
instance of an object.

Here are copies of some of the exceptions I am receiving:

************************************************** *********************
*
This one occurred while trying to log another error that occurred
************************************************** *********************
*
Error: Invalid access to memory location

DebugInfo:
-------- Exceptions --------
System.ComponentModel.Win32Exception: Invalid access to memory
location
at System.Diagnostics.EventLog.WriteEvent(Int32 eventID, Int16
category, EventLogEntryType type, String[] strings, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type, Int32 eventID, Int16 category)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type, Int32 eventID)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type)
at ReportDaemon.ReportDaemon.LogError(Exception e) in e:\web\arch
telecom test\portal2_1\reportdaemon\reportdaemon.cs:line 110
at ReportDaemon.Schedule.TimerCallback(Object data) in e:\web\arch
telecom test\portal2_1\reportdaemon\scheduler.cs:line 198

************************************************** *********************
*
I receive the following exception quite frequently, and believe the
root cause starts somewhere around here:
************************************************** *********************
*
Error: Object reference not set to an instance of an object.

DebugInfo:
-------- Exceptions --------
System.NullReferenceException: Object reference not set to an instance
of an object.
at System.Data.OleDb.DBPropSet.WritePropertySet()
at System.Data.OleDb.DBPropSet.WritePropertySet(Guid propertySet,
Int32 propertyCount)
at System.Data.OleDb.OleDbCommand.CommandPropertySets ()
at System.Data.OleDb.OleDbCommand.PropertyValueSetInt ernal()
at System.Data.OleDb.OleDbCommand.InitializeCommand(C ommandBehavior
behavior, Boolean throwifnotsupported)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior
behavior, Object& executeResult)
at
System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(Comma ndBehavior
behavior)
at
System.Data.OleDb.OleDbCommand.System.Data.IDbComm and.ExecuteReader(Com
mandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillFromCommand(O bject data,
Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand
command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at WebUtils.Databases.StoredProcedure.GetDataSet(Bool ean bValidate,
Boolean bRequireRows) in E:\web\Arch Telecom Test\Portal2_1\WebUtils
\Databases\DBNG.cs:line 582
at WebUtils.Databases.StoredProcedure.GetDataSet(Bool ean bValidate)
in E:\web\Arch Telecom Test\Portal2_1\WebUtils\Databases\DBNG.cs:line
518
at WebUtils.Databases.StoredProcedure.GetDataTable(Bo olean
bValidate) in E:\web\Arch Telecom Test\Portal2_1\WebUtils\Databases
\DBNG.cs:line 487
at
WebUtils.Databases.VSERV_DATABASES.IVRLOGDB.GetNex tReportForHTMLGenerat
ion() in E:\web\Arch Telecom Test\Portal2_1\WebUtils\Databases\VSERV
\IVRLOGDB.cs:line 62
at ReportDaemon.Schedules.ReportGenerator.Run() in E:\web\Arch
Telecom Test\Portal2_1\ReportDaemon\Schedules\ReportGenera tor.cs:line
138
at ReportDaemon.Schedule.TimerCallback(Object data) in e:\web\arch
telecom test\portal2_1\reportdaemon\scheduler.cs:line 194
************************************************** *********************
*
My personal favorite is this last setup, which I have yet to fully
identify. Basically and error gets thrown (another null reference
exception), but when I try and get the call stack information the
property throws another null reference exception. Basically it appears
as though the exception object itself is corrupt. I managed to run the
service from with visual studio, and setup a break-point to watch when
this happens. I copied the details of the exception from the visual
studio watch window, so the details are a little hard to read:

+ e {"Object reference not set to an instance of an object." }
System.Exception
- error {"Object reference not set to an instance of an object." }
System.Exception
- [System.NullReferenceException] {"Object reference not set to an
instance of an object." } System.NullReferenceException
- System.SystemException {"Object reference not set to an instance of
an object."} System.SystemException
- System.Exception {"Object reference not set to an instance of an
object." } System.Exception
System.Object {System.NullReferenceException} System.Object
_className null string
_COMPlusExceptionCode -532459699 int
- _exceptionMethod {System.Reflection.RuntimeMethodInfo}
System.Reflection.MethodBase
+ [System.Reflection.RuntimeMethodInfo]
{System.Reflection.RuntimeMethodInfo}
System.Reflection.RuntimeMethodInfo
+ System.Reflection.MemberInfo {System.Reflection.RuntimeMethodInfo}
System.Reflection.MemberInfo
Attributes 129 System.Reflection.MethodAttributes
CallingConvention 33 System.Reflection.CallingConventions
IsAbstract false bool
IsAssembly false bool
IsConstructor false bool
IsFamily false bool
IsFamilyAndAssembly false bool
IsFamilyOrAssembly false bool
IsFinal false bool
IsHideBySig true bool
IsOverloaded true bool
IsPrivate true bool
IsPublic false bool
IsSpecialName false bool
IsStatic false bool
IsVirtual false bool
+ MethodHandle {System.RuntimeMethodHandle} System.RuntimeMethodHandle
_exceptionMethodString null string
_helpURL null string
_HResult -2147467261 int
_innerException { } System.Exception
_message "Object reference not set to an instance of an object."
string
_remoteStackIndex 0 int
_remoteStackTraceString null string
_source null string
+ _stackTrace {System.Array} System.Object
_stackTraceString null string
_xcode -1073741819 int
_xptrs 78376988 int
HelpLink null string
HResult -2147467261 int
InnerException { } System.Exception
Message "Object reference not set to an instance of an object."
string
Source <error: an exception of type: {System.NullReferenceException}
occurred> string
StackTrace <error: an exception of type:
{System.NullReferenceException} occurred> string
+ TargetSite {System.Reflection.RuntimeMethodInfo}
System.Reflection.MethodBase
System.Object {System.NullReferenceException} System.Object
_className null string
_COMPlusExceptionCode -532459699 int
_exceptionMethod <undefined value> System.Reflection.MethodBase
_exceptionMethodString null string
_helpURL null string
_HResult -2147467261 int
_innerException { } System.Exception
_message "Object reference not set to an instance of an object."
string
_remoteStackIndex 0 int
_remoteStackTraceString null string
_source null string
- _stackTrace {System.Array} System.Object
[0] -100 sbyte
[1] -32 sbyte
[2] 28 sbyte
[3] 3 sbyte
[4] -88 sbyte
[5] -23 sbyte
[6] -85 sbyte
[7] 4 sbyte
[8] 24 sbyte
[9] 15 sbyte
[10] -19 sbyte
[11] 3 sbyte
[12] 30 sbyte
[13] -33 sbyte
[14] 28 sbyte
[15] 3 sbyte
[16] -108 sbyte
[17] -10 sbyte
[18] -85 sbyte
[19] 4 sbyte
[20] 40 sbyte
[21] 15 sbyte
[22] -19 sbyte
[23] 3 sbyte
[24] -124 sbyte
[25] -35 sbyte
[26] 28 sbyte
[27] 3 sbyte
[28] -64 sbyte
[29] -10 sbyte
[30] -85 sbyte
[31] 4 sbyte
[32] 72 sbyte
[33] 83 sbyte
[34] -104 sbyte
[35] 3 sbyte
[36] 122 sbyte
[37] -36 sbyte
[38] 28 sbyte
[39] 3 sbyte
[40] 0 sbyte
[41] -9 sbyte
[42] -85 sbyte
[43] 4 sbyte
[44] 24 sbyte
[45] 83 sbyte
[46] -104 sbyte
[47] 3 sbyte
[48] 58 sbyte
[49] -38 sbyte
[50] 28 sbyte
[51] 3 sbyte
[52] 48 sbyte
[53] -9 sbyte
[54] -85 sbyte
[55] 4 sbyte
[56] -104 sbyte
[57] 82 sbyte
[58] -104 sbyte
[59] 3 sbyte
[60] 0 sbyte
[61] -39 sbyte
[62] 28 sbyte
[63] 3 sbyte
[64] -128 sbyte
[65] -9 sbyte
[66] -85 sbyte
[67] 4 sbyte
[68] -120 sbyte
[69] 81 sbyte
[70] -104 sbyte
[71] 3 sbyte
[72] -118 sbyte
[73] -46 sbyte
[74] 28 sbyte
[75] 3 sbyte
[76] -96 sbyte
[77] -9 sbyte
[78] -85 sbyte
[79] 4 sbyte
[80] 120 sbyte
[81] 81 sbyte
[82] -104 sbyte
[83] 3 sbyte
[84] -21 sbyte
[85] -49 sbyte
[86] 28 sbyte
[87] 3 sbyte
[88] -84 sbyte
[89] -9 sbyte
[90] -85 sbyte
[91] 4 sbyte
[92] 104 sbyte
[93] 81 sbyte
[94] -104 sbyte
[95] 3 sbyte
[96] 118 sbyte
[97] -49 sbyte
[98] 28 sbyte
[99] 3 sbyte
[100] 40 sbyte
[101] -8 sbyte
[102] -85 sbyte
[103] 4 sbyte
[104] 88 sbyte
[105] 84 sbyte
[106] -104 sbyte
[107] 3 sbyte
[108] 71 sbyte
[109] -61 sbyte
[110] 28 sbyte
[111] 3 sbyte
[112] -4 sbyte
[113] -9 sbyte
[114] -85 sbyte
[115] 4 sbyte
[116] 88 sbyte
[117] -75 sbyte
[118] -104 sbyte
[119] 3 sbyte
[120] -63 sbyte
[121] -63 sbyte
[122] 28 sbyte
[123] 3 sbyte
[124] -100 sbyte
[125] -8 sbyte
[126] -85 sbyte
[127] 4 sbyte
[128] 56 sbyte
[129] -75 sbyte
[130] -104 sbyte
[131] 3 sbyte
[132] -121 sbyte
[133] -64 sbyte
[134] 28 sbyte
[135] 3 sbyte
[136] -52 sbyte
[137] -8 sbyte
[138] -85 sbyte
[139] 4 sbyte
[140] 8 sbyte
[141] -75 sbyte
[142] -104 sbyte
[143] 3 sbyte
[144] -67 sbyte
[145] 108 sbyte
[146] 28 sbyte
[147] 3 sbyte
[148] -8 sbyte
[149] -8 sbyte
[150] -85 sbyte
[151] 4 sbyte
[152] -104 sbyte
[153] 57 sbyte
[154] -104 sbyte
[155] 3 sbyte
[156] -62 sbyte
[157] 107 sbyte
[158] 28 sbyte
[159] 3 sbyte
[160] 100 sbyte
[161] -7 sbyte
[162] -85 sbyte
[163] 4 sbyte
[164] 104 sbyte
[165] 57 sbyte
[166] -104 sbyte
[167] 3 sbyte
[168] 46 sbyte
[169] 107 sbyte
[170] 28 sbyte
[171] 3 sbyte
[172] -124 sbyte
[173] -7 sbyte
[174] -85 sbyte
[175] 4 sbyte
[176] 72 sbyte
[177] 57 sbyte
[178] -104 sbyte
[179] 3 sbyte
[180] -64 sbyte
[181] -71 sbyte
[182] 28 sbyte
[183] 3 sbyte
[184] -84 sbyte
[185] -7 sbyte
[186] -85 sbyte
[187] 4 sbyte
[188] 48 sbyte
[189] 17 sbyte
[190] -104 sbyte
[191] 3 sbyte
[192] 23 sbyte
[193] -80 sbyte
[194] 28 sbyte
[195] 3 sbyte
[196] -36 sbyte
[197] -7 sbyte
[198] -85 sbyte
[199] 4 sbyte
[200] -16 sbyte
[201] -128 sbyte
[202] -121 sbyte
[203] 0 sbyte
[204] -91 sbyte
[205] 49 sbyte
[206] 28 sbyte
[207] 3 sbyte
[208] -68 sbyte
[209] -6 sbyte
[210] -85 sbyte
[211] 4 sbyte
[212] -40 sbyte
[213] 107 sbyte
[214] -121 sbyte
[215] 0 sbyte
_stackTraceString null string
_xcode -1073741819 int
_xptrs 78376988 int
HelpLink null string
HResult -2147467261 int
InnerException { } System.Exception
Message "Object reference not set to an instance of an object."
string
Source <error: an exception of type: {System.NullReferenceException}
occurred> string
StackTrace <error: an exception of type:
{System.NullReferenceException} occurred> string
- TargetSite {System.Reflection.RuntimeMethodInfo}
System.Reflection.MethodBase
+ [System.Reflection.RuntimeMethodInfo]
{System.Reflection.RuntimeMethodInfo}
System.Reflection.RuntimeMethodInfo
+ System.Reflection.MemberInfo {System.Reflection.RuntimeMethodInfo}
System.Reflection.MemberInfo
Attributes 129 System.Reflection.MethodAttributes
CallingConvention 33 System.Reflection.CallingConventions
IsAbstract false bool
IsAssembly false bool
IsConstructor false bool
IsFamily false bool
IsFamilyAndAssembly false bool
IsFamilyOrAssembly false bool
IsFinal false bool
IsHideBySig true bool
IsOverloaded true bool
IsPrivate true bool
IsPublic false bool
IsSpecialName false bool
IsStatic false bool
IsVirtual false bool
+ MethodHandle {System.RuntimeMethodHandle} System.RuntimeMethodHandle

Jan 30 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hi
Whoaa, that was a LONG message :)

Problems in multi threaded apps are always a problem to debug. I would start
by making sure that there are no isntnaces variables being used in the
threads.

Could you post some code?

--
Ignacio Machin
machin AT laceupsolutions com
Jan 30 '07 #2

P: n/a
The different threads don't share instance variables. Basically, the
way my app is setup is I have a notion of a schedule. A schedule will
perform a specific task and return. This schedule is run at a
predefined internal. There are multiple schedules, but the schedules
do not share variables. The main complaint I have with my own code is
the way I'm choosing to execute the schedules. My problem is I need to
run a function at a time interval but if a previous invocation takes
longer that the interval the next invocation should wait until the
previous one is finished. I am posting my root class that shows this
behavior. Basically, when I want to create a new schedule I inherit
from this class, and override the run method.

using System;
using System.Net;
using System.Threading;
using System.Diagnostics;
using System.Reflection;
using System.Collections;
using WebUtils;
using WebUtils.Databases;

namespace ReportDaemon {
/// <summary>
/// A schedule must inherit from this class to be run
/// </summary>
/// <remarks>
/// <b>Creating a new Schedule:</b>
/// <br />
/// To create a new schedule, you should first
create a new file inside
/// the ReportDaemon/Schedules folder. This file
will contain the new
/// Schedule class. The new class should inherit
from the ReportDaemon.Schedule
/// class. Then there are several fields and
methods you should override:
/// <code>
/// namespace ReportDaemon.Schedules {
/// /// &lt;summary&gt;
/// /// A New Schedule
/// /// &lt;/summary&gt;
/// public class NewSchedule :
Schedule {
/// /// &lt;summary&gt;
/// /// Constructs the
Schedule
/// /// &lt;/summary&gt;
/// public NewSchedule() :
base() {
/// //If an error
is thrown in the constructor of a
/// //schedule,
the Report Daemon as a whole will not
/// //start.
///
/// //Save most of
the initialization for this call back
/// base.OnInit +=
new EventCallback( Init );
/// }
///
/// private void Init() {
/// //If an error
is thrown in this method,
/// //Then this
schedule will not run, but
/// //the
ReportDaemon will attempt to initialize
/// //this
schedule again later.
/// }
///
/// /// &lt;summary&gt;
/// /// Determines whether
or not this schedule is enabled. If it is
/// /// not enabled, it
will not run
/// /// &lt;/summary&gt;
/// public override bool
Enabled {
/// get {
/// ...
/// }
/// }
///
/// /// &lt;summary&gt;
/// /// Determines the
rate at which to run this schedule
/// /// &lt;/summary&gt;
/// public override
TimeSpan RunRate {
/// get {
/// ...
/// }
/// }
///
/// /// &lt;summary&gt;
/// /// Runs schedule
specific code, only
/// /// one thread will be
running this method
/// /// at a given time
/// /// &lt;/summary&gt;
/// public override void
Run() {
/// ...
/// }
/// }
/// }
/// </code>
/// The constructor for the class should take no
arguments. In addition, most of the complex
/// initialization work should not be done in the
constructor. This is because if any schedule
/// fails to construct, the ReportDaemon as a
whole will fail to start. Instead, hook into the
/// OnInit event and perform you complex
initialization in there. The enabled method is used
/// to disable or enable certain schedules (Like
if the schedule is still under development,
/// or you are testing, and you don't want a
particular schedule to run while you are testing).
/// The run rate is a TimeSpan object that
dictates how frequently the schedule should run.
/// The Cookie Cleanup schedule runs rather
infrequently (like once an hour). Lastly, there is
/// the run method. This method handles the
schedule specific code. In this method is where you
/// should run your procedures against the
database. A reference to the databases can be found
/// in the base DatabaseServers object.
/// <br />
/// </remarks>
public abstract class Schedule : IDisposable {
private Timer timer;
private Mutex runOnce = new Mutex();
private WaitHandle shutdown = new
AutoResetEvent( false );
private int errorCount = 0;
private bool isRunning = false;

/// <summary>
/// The name of this schedule
/// </summary>
public readonly string Name;

/// <summary>An event callback delegate</summary>
protected delegate void EventCallback();
/// <summary>Called when the schedule is initialized</
summary>
protected event EventCallback OnInit;
/// <summary>A Reference to the Database Servers</
summary>
protected DBNG DatabaseServers = null;

/// <summary>
/// Constructs the Schedule object
/// </summary>
public Schedule() {
Name = GetType().Name;
DatabaseServers = new
DBNG( Config.AppSettings.HostName + "/ReportDaemon/" + Name );
}

/// <summary>
/// Initializes this schedule and invokes on OnInit
event.
/// Once called successfully the schedule will run. If
/// this fails the schedule with not run.
/// </summary>
public void Initialize() {
if( null != OnInit ) {
OnInit();
}

//The last thing done, so the schedule won't
run unless the init is done successfully
//Initially this schedule should run
immediately
isRunning = true;
timer = new Timer( new
TimerCallback( this.TimerCallback ), null, 0, Timeout.Infinite );
}

/// <summary>
/// Determines if the schedule has been properly
initialized
/// </summary>
public bool IsInitialized {
get {
return null != timer;
}
}

/// <summary>
/// A shortcut for inherited classes
/// </summary>
protected VSERV vserv {
get {
return DatabaseServers.vserv;
}
}

/// <summary>
/// A shortcut for inherited classes
/// </summary>
protected VBSERV vbserv {
get {
return DatabaseServers.vbserv;
}
}

/// <summary>
/// Must be overridden, the rate at which this
schedule is run
/// </summary>
public abstract TimeSpan RunRate{ get; }

/// <summary>
/// Must be overridden, if false the schedule will not
be run
/// </summary>
public abstract bool Enabled{ get; }

/// <summary>
/// How long the current schedule has been executing
(0 if its not executing).
/// </summary>
public TimeSpan ExecutionTime {
get {
DateTime start = startedExecuting;
if( DateTime.MinValue != start ) {
return
DateTime.Now.Subtract( start );
}
return TimeSpan.Zero;
}
}
private DateTime startedExecuting = DateTime.MinValue;

/// <summary>
/// A wrapper to do some maintenance before and after
a schedule is run
/// </summary>
private void TimerCallback( object data ) {
//BE: Put it out here to ensure errors get
logged before running it again
lock( runOnce ) { //If it gets called again
before the first time finished it should block here
try {
startedExecuting =
DateTime.Now;
if( isRunning ) {

EventLogger.LogInfo( "Running " + Name );

timer.Change( (int)RunRate.TotalMilliseconds, Timeout.Infinite ); //
Set it to run again
Run();
errorCount = 0;
}
} catch( Exception e ) {
ReportDaemon.LogError( e );
if( ++errorCount == 3 ) {
throw new
Exception( "Due to excessive errors in the schedule " + Name + ", the
ReportDaemon is stopping itself." );
}
} finally {
startedExecuting =
DateTime.MinValue;
}
}
}

/// <summary>
/// Must be overridden, and is the method that gets
run on a schedule
/// </summary>
protected abstract void Run();

/// <summary>
/// Prevents the schedule from running further
/// </summary>
public void Pause() {
Monitor.Enter( runOnce );
}

/// <summary>
/// Resumes execution of the schedule
/// </summary>
public void Resume() {
Monitor.Exit( runOnce );
}

/// <summary>
/// Signals the thread to start shutting down
/// </summary>
public void StartShuttingdown() {
isRunning = false;
}

/// <summary>
/// Perform any cleanup in this method
/// </summary>
public virtual void Dispose() {
EventLogger.LogInfo( "Disposing " + Name );
if( IsInitialized ) {
isRunning = false;

if( !Monitor.TryEnter( runOnce,
5000 ) ) {
EventLogger.LogInfo( Name + "
appears to be blocked." );
}

timer.Dispose( shutdown );
if( !shutdown.WaitOne( 2000, false ) )
{
EventLogger.LogInfo( Name + "
failed to dispose properly." );
}
}
EventLogger.LogInfo( "Disposed " + Name );
}
}
}

Jan 30 '07 #3

P: n/a
A big guess. I had some time ago somewhat similar behavior with a windows
service, and found out that the finalizer queue was running full. I added a
periodic GC.WaitForPendingFinalizers(), checked and corrected all disposings
and added finalizers on classes that had disposable objects.
After that, no problems so far..

LT
<br*************@gmail.comha scritto nel messaggio
news:11**********************@a75g2000cwd.googlegr oups.com...
>I have written a multi-threaded c# windows service in .net 1.1 (Visual
Studio .net 2003). The service has several threads that poll a Sql 6.5
database on another machine. Each thread will execute a stored
procedure, and the results are used to determine if there is anything
for this particular thread to do. My problem is that I periodically
get exceptions from places that normally shouldn't get exceptions. The
service can run find for hours (10+). Then sometimes it will having a
null reference exceptions and the service crashes and restarts.

Most exceptions are of the type:
System.NullReferenceException: Object reference not set to an
instance of an object.

Here are copies of some of the exceptions I am receiving:

************************************************** *********************
*
This one occurred while trying to log another error that occurred
************************************************** *********************
*
Error: Invalid access to memory location

DebugInfo:
-------- Exceptions --------
System.ComponentModel.Win32Exception: Invalid access to memory
location
at System.Diagnostics.EventLog.WriteEvent(Int32 eventID, Int16
category, EventLogEntryType type, String[] strings, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type, Int32 eventID, Int16 category)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type, Int32 eventID)
at System.Diagnostics.EventLog.WriteEntry(String message,
EventLogEntryType type)
at ReportDaemon.ReportDaemon.LogError(Exception e) in e:\web\arch
telecom test\portal2_1\reportdaemon\reportdaemon.cs:line 110
at ReportDaemon.Schedule.TimerCallback(Object data) in e:\web\arch
telecom test\portal2_1\reportdaemon\scheduler.cs:line 198

************************************************** *********************
*
I receive the following exception quite frequently, and believe the
root cause starts somewhere around here:
************************************************** *********************
*
Error: Object reference not set to an instance of an object.

DebugInfo:
-------- Exceptions --------
System.NullReferenceException: Object reference not set to an instance
of an object.
at System.Data.OleDb.DBPropSet.WritePropertySet()
at System.Data.OleDb.DBPropSet.WritePropertySet(Guid propertySet,
Int32 propertyCount)
at System.Data.OleDb.OleDbCommand.CommandPropertySets ()
at System.Data.OleDb.OleDbCommand.PropertyValueSetInt ernal()
at System.Data.OleDb.OleDbCommand.InitializeCommand(C ommandBehavior
behavior, Boolean throwifnotsupported)
at System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior
behavior, Object& executeResult)
at
System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior
behavior, String method)
at System.Data.OleDb.OleDbCommand.ExecuteReader(Comma ndBehavior
behavior)
at
System.Data.OleDb.OleDbCommand.System.Data.IDbComm and.ExecuteReader(Com
mandBehavior behavior)
at System.Data.Common.DbDataAdapter.FillFromCommand(O bject data,
Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand
command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
at WebUtils.Databases.StoredProcedure.GetDataSet(Bool ean bValidate,
Boolean bRequireRows) in E:\web\Arch Telecom Test\Portal2_1\WebUtils
\Databases\DBNG.cs:line 582
at WebUtils.Databases.StoredProcedure.GetDataSet(Bool ean bValidate)
in E:\web\Arch Telecom Test\Portal2_1\WebUtils\Databases\DBNG.cs:line
518
at WebUtils.Databases.StoredProcedure.GetDataTable(Bo olean
bValidate) in E:\web\Arch Telecom Test\Portal2_1\WebUtils\Databases
\DBNG.cs:line 487
at
WebUtils.Databases.VSERV_DATABASES.IVRLOGDB.GetNex tReportForHTMLGenerat
ion() in E:\web\Arch Telecom Test\Portal2_1\WebUtils\Databases\VSERV
\IVRLOGDB.cs:line 62
at ReportDaemon.Schedules.ReportGenerator.Run() in E:\web\Arch
Telecom Test\Portal2_1\ReportDaemon\Schedules\ReportGenera tor.cs:line
138
at ReportDaemon.Schedule.TimerCallback(Object data) in e:\web\arch
telecom test\portal2_1\reportdaemon\scheduler.cs:line 194
************************************************** *********************
*
My personal favorite is this last setup, which I have yet to fully
identify. Basically and error gets thrown (another null reference
exception), but when I try and get the call stack information the
property throws another null reference exception. Basically it appears
as though the exception object itself is corrupt. I managed to run the
service from with visual studio, and setup a break-point to watch when
this happens. I copied the details of the exception from the visual
studio watch window, so the details are a little hard to read:

+ e {"Object reference not set to an instance of an object." }
System.Exception
- error {"Object reference not set to an instance of an object." }
System.Exception
- [System.NullReferenceException] {"Object reference not set to an
instance of an object." } System.NullReferenceException
- System.SystemException {"Object reference not set to an instance of
an object."} System.SystemException
- System.Exception {"Object reference not set to an instance of an
object." } System.Exception
System.Object {System.NullReferenceException} System.Object
_className null string
_COMPlusExceptionCode -532459699 int
- _exceptionMethod {System.Reflection.RuntimeMethodInfo}
System.Reflection.MethodBase
+ [System.Reflection.RuntimeMethodInfo]
{System.Reflection.RuntimeMethodInfo}
System.Reflection.RuntimeMethodInfo
+ System.Reflection.MemberInfo {System.Reflection.RuntimeMethodInfo}
System.Reflection.MemberInfo
Attributes 129 System.Reflection.MethodAttributes
CallingConvention 33 System.Reflection.CallingConventions
IsAbstract false bool
IsAssembly false bool
IsConstructor false bool
IsFamily false bool
IsFamilyAndAssembly false bool
IsFamilyOrAssembly false bool
IsFinal false bool
IsHideBySig true bool
IsOverloaded true bool
IsPrivate true bool
IsPublic false bool
IsSpecialName false bool
IsStatic false bool
IsVirtual false bool
+ MethodHandle {System.RuntimeMethodHandle} System.RuntimeMethodHandle
_exceptionMethodString null string
_helpURL null string
_HResult -2147467261 int
_innerException { } System.Exception
_message "Object reference not set to an instance of an object."
string
_remoteStackIndex 0 int
_remoteStackTraceString null string
_source null string
+ _stackTrace {System.Array} System.Object
_stackTraceString null string
_xcode -1073741819 int
_xptrs 78376988 int
HelpLink null string
HResult -2147467261 int
InnerException { } System.Exception
Message "Object reference not set to an instance of an object."
string
Source <error: an exception of type: {System.NullReferenceException}
occurredstring
StackTrace <error: an exception of type:
{System.NullReferenceException} occurredstring
+ TargetSite {System.Reflection.RuntimeMethodInfo}
System.Reflection.MethodBase
System.Object {System.NullReferenceException} System.Object
_className null string
_COMPlusExceptionCode -532459699 int
_exceptionMethod <undefined valueSystem.Reflection.MethodBase
_exceptionMethodString null string
_helpURL null string
_HResult -2147467261 int
_innerException { } System.Exception
_message "Object reference not set to an instance of an object."
string
_remoteStackIndex 0 int
_remoteStackTraceString null string
_source null string
- _stackTrace {System.Array} System.Object
[0] -100 sbyte
[1] -32 sbyte
[2] 28 sbyte
[3] 3 sbyte
[4] -88 sbyte
[5] -23 sbyte
[6] -85 sbyte
[7] 4 sbyte
[8] 24 sbyte
[9] 15 sbyte
[10] -19 sbyte
[11] 3 sbyte
[12] 30 sbyte
[13] -33 sbyte
[14] 28 sbyte
[15] 3 sbyte
[16] -108 sbyte
[17] -10 sbyte
[18] -85 sbyte
[19] 4 sbyte
[20] 40 sbyte
[21] 15 sbyte
[22] -19 sbyte
[23] 3 sbyte
[24] -124 sbyte
[25] -35 sbyte
[26] 28 sbyte
[27] 3 sbyte
[28] -64 sbyte
[29] -10 sbyte
[30] -85 sbyte
[31] 4 sbyte
[32] 72 sbyte
[33] 83 sbyte
[34] -104 sbyte
[35] 3 sbyte
[36] 122 sbyte
[37] -36 sbyte
[38] 28 sbyte
[39] 3 sbyte
[40] 0 sbyte
[41] -9 sbyte
[42] -85 sbyte
[43] 4 sbyte
[44] 24 sbyte
[45] 83 sbyte
[46] -104 sbyte
[47] 3 sbyte
[48] 58 sbyte
[49] -38 sbyte
[50] 28 sbyte
[51] 3 sbyte
[52] 48 sbyte
[53] -9 sbyte
[54] -85 sbyte
[55] 4 sbyte
[56] -104 sbyte
[57] 82 sbyte
[58] -104 sbyte
[59] 3 sbyte
[60] 0 sbyte
[61] -39 sbyte
[62] 28 sbyte
[63] 3 sbyte
[64] -128 sbyte
[65] -9 sbyte
[66] -85 sbyte
[67] 4 sbyte
[68] -120 sbyte
[69] 81 sbyte
[70] -104 sbyte
[71] 3 sbyte
[72] -118 sbyte
[73] -46 sbyte
[74] 28 sbyte
[75] 3 sbyte
[76] -96 sbyte
[77] -9 sbyte
[78] -85 sbyte
[79] 4 sbyte
[80] 120 sbyte
[81] 81 sbyte
[82] -104 sbyte
[83] 3 sbyte
[84] -21 sbyte
[85] -49 sbyte
[86] 28 sbyte
[87] 3 sbyte
[88] -84 sbyte
[89] -9 sbyte
[90] -85 sbyte
[91] 4 sbyte
[92] 104 sbyte
[93] 81 sbyte
[94] -104 sbyte
[95] 3 sbyte
[96] 118 sbyte
[97] -49 sbyte
[98] 28 sbyte
[99] 3 sbyte
[100] 40 sbyte
[101] -8 sbyte
[102] -85 sbyte
[103] 4 sbyte
[104] 88 sbyte
[105] 84 sbyte
[106] -104 sbyte
[107] 3 sbyte
[108] 71 sbyte
[109] -61 sbyte
[110] 28 sbyte
[111] 3 sbyte
[112] -4 sbyte
[113] -9 sbyte
[114] -85 sbyte
[115] 4 sbyte
[116] 88 sbyte
[117] -75 sbyte
[118] -104 sbyte
[119] 3 sbyte
[120] -63 sbyte
[121] -63 sbyte
[122] 28 sbyte
[123] 3 sbyte
[124] -100 sbyte
[125] -8 sbyte
[126] -85 sbyte
[127] 4 sbyte
[128] 56 sbyte
[129] -75 sbyte
[130] -104 sbyte
[131] 3 sbyte
[132] -121 sbyte
[133] -64 sbyte
[134] 28 sbyte
[135] 3 sbyte
[136] -52 sbyte
[137] -8 sbyte
[138] -85 sbyte
[139] 4 sbyte
[140] 8 sbyte
[141] -75 sbyte
[142] -104 sbyte
[143] 3 sbyte
[144] -67 sbyte
[145] 108 sbyte
[146] 28 sbyte
[147] 3 sbyte
[148] -8 sbyte
[149] -8 sbyte
[150] -85 sbyte
[151] 4 sbyte
[152] -104 sbyte
[153] 57 sbyte
[154] -104 sbyte
[155] 3 sbyte
[156] -62 sbyte
[157] 107 sbyte
[158] 28 sbyte
[159] 3 sbyte
[160] 100 sbyte
[161] -7 sbyte
[162] -85 sbyte
[163] 4 sbyte
[164] 104 sbyte
[165] 57 sbyte
[166] -104 sbyte
[167] 3 sbyte
[168] 46 sbyte
[169] 107 sbyte
[170] 28 sbyte
[171] 3 sbyte
[172] -124 sbyte
[173] -7 sbyte
[174] -85 sbyte
[175] 4 sbyte
[176] 72 sbyte
[177] 57 sbyte
[178] -104 sbyte
[179] 3 sbyte
[180] -64 sbyte
[181] -71 sbyte
[182] 28 sbyte
[183] 3 sbyte
[184] -84 sbyte
[185] -7 sbyte
[186] -85 sbyte
[187] 4 sbyte
[188] 48 sbyte
[189] 17 sbyte
[190] -104 sbyte
[191] 3 sbyte
[192] 23 sbyte
[193] -80 sbyte
[194] 28 sbyte
[195] 3 sbyte
[196] -36 sbyte
[197] -7 sbyte
[198] -85 sbyte
[199] 4 sbyte
[200] -16 sbyte
[201] -128 sbyte
[202] -121 sbyte
[203] 0 sbyte
[204] -91 sbyte
[205] 49 sbyte
[206] 28 sbyte
[207] 3 sbyte
[208] -68 sbyte
[209] -6 sbyte
[210] -85 sbyte
[211] 4 sbyte
[212] -40 sbyte
[213] 107 sbyte
[214] -121 sbyte
[215] 0 sbyte
_stackTraceString null string
_xcode -1073741819 int
_xptrs 78376988 int
HelpLink null string
HResult -2147467261 int
InnerException { } System.Exception
Message "Object reference not set to an instance of an object."
string
Source <error: an exception of type: {System.NullReferenceException}
occurredstring
StackTrace <error: an exception of type:
{System.NullReferenceException} occurredstring
- TargetSite {System.Reflection.RuntimeMethodInfo}
System.Reflection.MethodBase
+ [System.Reflection.RuntimeMethodInfo]
{System.Reflection.RuntimeMethodInfo}
System.Reflection.RuntimeMethodInfo
+ System.Reflection.MemberInfo {System.Reflection.RuntimeMethodInfo}
System.Reflection.MemberInfo
Attributes 129 System.Reflection.MethodAttributes
CallingConvention 33 System.Reflection.CallingConventions
IsAbstract false bool
IsAssembly false bool
IsConstructor false bool
IsFamily false bool
IsFamilyAndAssembly false bool
IsFamilyOrAssembly false bool
IsFinal false bool
IsHideBySig true bool
IsOverloaded true bool
IsPrivate true bool
IsPublic false bool
IsSpecialName false bool
IsStatic false bool
IsVirtual false bool
+ MethodHandle {System.RuntimeMethodHandle} System.RuntimeMethodHandle

Jan 31 '07 #4

P: n/a
Is it possible to monitor the finalizer queue, so I can see if its
getting too big? I read something a while back that suggested
something similiar to what you are saying, and I added a
GC.WaitForPendingFinalizers(), but I wonder if I am still not calling
it frequently enough.

Jan 31 '07 #5

P: n/a
The only two ways I know to check how finalizer is doing is to use
performance monitor (Finalizing survivors) and using WinDBG/SOS (command
!finalizequeue).
The most problems I know about finalizers are related to COM and COM+ (and
you did have an COM+ exception in your stack trace).

<br*************@gmail.comha scritto nel messaggio
news:11**********************@j27g2000cwj.googlegr oups.com...
Is it possible to monitor the finalizer queue, so I can see if its
getting too big? I read something a while back that suggested
something similiar to what you are saying, and I added a
GC.WaitForPendingFinalizers(), but I wonder if I am still not calling
it frequently enough.

Feb 1 '07 #6

P: n/a
"Laura T." <LT@NOWHERE.COMwrote in message news:uo**************@TK2MSFTNGP04.phx.gbl...
The only two ways I know to check how finalizer is doing is to use performance monitor
(Finalizing survivors) and using WinDBG/SOS (command !finalizequeue).
The most problems I know about finalizers are related to COM and COM+ (and you did have an
COM+ exception in your stack trace).
Don't get confused by the COMPlusExceptionCode -532459699 int,
this is the CLR Structured Exception Handler code, note that the CLR is (internally) called
COM3 (or COM+ v3). The SEH code in hex E0434F4D has "COM" as the last three characters.

Willy.

Feb 1 '07 #7

P: n/a
I added the GC.WaitForPendingFinalizers() that runs every 30 seconds
now, and it didn't seem to work. So I added another call that happens
after a report is generated (This would be the place that allocates
and deallocates the most objects). We'll see what happens with this.

My next issue, is I'm having trouble debugging this. The main reason
is if I catch an exception that is corrupted, and try and handle it
(I.E. log it so I can see whats going on in production) the behavior
of the application is unpredictable. Sometimes it locks up, and
sometimes exceptions propogate all the way up so they crash the
application. If it crashes the application, that is acceptable because
windows will just restart the service. However, if the application
locks up, then nothing works until someone realizes this and
intervenes.

So some questions on this:
1) What is the best way to handle say an out of memory exception. Can
you simply rethrow it if you really are out of memory?
2) If the finalizer queue is getting full, why does it not throw an
outofmemory exception instead of returning null?
A) Is it possible the outofmemory exception is getting throw, but
ado.net is catching this error and trying to recover?
3) How large is too large for the surviving finalizer queue? (I never
saw it break 100)

Feb 1 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.