473,657 Members | 2,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unusual C# errors (Maybe memory corruption)

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.NullRefe renceException: 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.Componen tModel.Win32Exc eption: Invalid access to memory
location
at System.Diagnost ics.EventLog.Wr iteEvent(Int32 eventID, Int16
category, EventLogEntryTy pe type, String[] strings, Byte[] rawData)
at System.Diagnost ics.EventLog.Wr iteEntry(String message,
EventLogEntryTy pe type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnost ics.EventLog.Wr iteEntry(String message,
EventLogEntryTy pe type, Int32 eventID, Int16 category)
at System.Diagnost ics.EventLog.Wr iteEntry(String message,
EventLogEntryTy pe type, Int32 eventID)
at System.Diagnost ics.EventLog.Wr iteEntry(String message,
EventLogEntryTy pe type)
at ReportDaemon.Re portDaemon.LogE rror(Exception e) in e:\web\arch
telecom test\portal2_1\ reportdaemon\re portdaemon.cs:l ine 110
at ReportDaemon.Sc hedule.TimerCal lback(Object data) in e:\web\arch
telecom test\portal2_1\ reportdaemon\sc heduler.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.NullRefe renceException: Object reference not set to an instance
of an object.
at System.Data.Ole Db.DBPropSet.Wr itePropertySet( )
at System.Data.Ole Db.DBPropSet.Wr itePropertySet( Guid propertySet,
Int32 propertyCount)
at System.Data.Ole Db.OleDbCommand .CommandPropert ySets()
at System.Data.Ole Db.OleDbCommand .PropertyValueS etInternal()
at System.Data.Ole Db.OleDbCommand .InitializeComm and(CommandBeha vior
behavior, Boolean throwifnotsuppo rted)
at System.Data.Ole Db.OleDbCommand .ExecuteCommand (CommandBehavio r
behavior, Object& executeResult)
at
System.Data.Ole Db.OleDbCommand .ExecuteReaderI nternal(Command Behavior
behavior, String method)
at System.Data.Ole Db.OleDbCommand .ExecuteReader( CommandBehavior
behavior)
at
System.Data.Ole Db.OleDbCommand .System.Data.ID bCommand.Execut eReader(Com
mandBehavior behavior)
at System.Data.Com mon.DbDataAdapt er.FillFromComm and(Object data,
Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand
command, CommandBehavior behavior)
at System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet)
at WebUtils.Databa ses.StoredProce dure.GetDataSet (Boolean bValidate,
Boolean bRequireRows) in E:\web\Arch Telecom Test\Portal2_1\ WebUtils
\Databases\DBNG .cs:line 582
at WebUtils.Databa ses.StoredProce dure.GetDataSet (Boolean bValidate)
in E:\web\Arch Telecom Test\Portal2_1\ WebUtils\Databa ses\DBNG.cs:lin e
518
at WebUtils.Databa ses.StoredProce dure.GetDataTab le(Boolean
bValidate) in E:\web\Arch Telecom Test\Portal2_1\ WebUtils\Databa ses
\DBNG.cs:line 487
at
WebUtils.Databa ses.VSERV_DATAB ASES.IVRLOGDB.G etNextReportFor HTMLGenerat
ion() in E:\web\Arch Telecom Test\Portal2_1\ WebUtils\Databa ses\VSERV
\IVRLOGDB.cs:li ne 62
at ReportDaemon.Sc hedules.ReportG enerator.Run() in E:\web\Arch
Telecom Test\Portal2_1\ ReportDaemon\Sc hedules\ReportG enerator.cs:lin e
138
at ReportDaemon.Sc hedule.TimerCal lback(Object data) in e:\web\arch
telecom test\portal2_1\ reportdaemon\sc heduler.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.Exceptio n
- error {"Object reference not set to an instance of an object." }
System.Exceptio n
- [System.NullRefe renceException] {"Object reference not set to an
instance of an object." } System.NullRefe renceException
- System.SystemEx ception {"Object reference not set to an instance of
an object."} System.SystemEx ception
- System.Exceptio n {"Object reference not set to an instance of an
object." } System.Exceptio n
System.Object {System.NullRef erenceException } System.Object
_className null string
_COMPlusExcepti onCode -532459699 int
- _exceptionMetho d {System.Reflect ion.RuntimeMeth odInfo}
System.Reflecti on.MethodBase
+ [System.Reflecti on.RuntimeMetho dInfo]
{System.Reflect ion.RuntimeMeth odInfo}
System.Reflecti on.RuntimeMetho dInfo
+ System.Reflecti on.MemberInfo {System.Reflect ion.RuntimeMeth odInfo}
System.Reflecti on.MemberInfo
Attributes 129 System.Reflecti on.MethodAttrib utes
CallingConventi on 33 System.Reflecti on.CallingConve ntions
IsAbstract false bool
IsAssembly false bool
IsConstructor false bool
IsFamily false bool
IsFamilyAndAsse mbly false bool
IsFamilyOrAssem bly 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.Runtime MethodHandle} System.RuntimeM ethodHandle
_exceptionMetho dString null string
_helpURL null string
_HResult -2147467261 int
_innerException { } System.Exceptio n
_message "Object reference not set to an instance of an object."
string
_remoteStackInd ex 0 int
_remoteStackTra ceString null string
_source null string
+ _stackTrace {System.Array} System.Object
_stackTraceStri ng null string
_xcode -1073741819 int
_xptrs 78376988 int
HelpLink null string
HResult -2147467261 int
InnerException { } System.Exceptio n
Message "Object reference not set to an instance of an object."
string
Source <error: an exception of type: {System.NullRef erenceException }
occurred> string
StackTrace <error: an exception of type:
{System.NullRef erenceException } occurred> string
+ TargetSite {System.Reflect ion.RuntimeMeth odInfo}
System.Reflecti on.MethodBase
System.Object {System.NullRef erenceException } System.Object
_className null string
_COMPlusExcepti onCode -532459699 int
_exceptionMetho d <undefined value> System.Reflecti on.MethodBase
_exceptionMetho dString null string
_helpURL null string
_HResult -2147467261 int
_innerException { } System.Exceptio n
_message "Object reference not set to an instance of an object."
string
_remoteStackInd ex 0 int
_remoteStackTra ceString 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
_stackTraceStri ng null string
_xcode -1073741819 int
_xptrs 78376988 int
HelpLink null string
HResult -2147467261 int
InnerException { } System.Exceptio n
Message "Object reference not set to an instance of an object."
string
Source <error: an exception of type: {System.NullRef erenceException }
occurred> string
StackTrace <error: an exception of type:
{System.NullRef erenceException } occurred> string
- TargetSite {System.Reflect ion.RuntimeMeth odInfo}
System.Reflecti on.MethodBase
+ [System.Reflecti on.RuntimeMetho dInfo]
{System.Reflect ion.RuntimeMeth odInfo}
System.Reflecti on.RuntimeMetho dInfo
+ System.Reflecti on.MemberInfo {System.Reflect ion.RuntimeMeth odInfo}
System.Reflecti on.MemberInfo
Attributes 129 System.Reflecti on.MethodAttrib utes
CallingConventi on 33 System.Reflecti on.CallingConve ntions
IsAbstract false bool
IsAssembly false bool
IsConstructor false bool
IsFamily false bool
IsFamilyAndAsse mbly false bool
IsFamilyOrAssem bly 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.Runtime MethodHandle} System.RuntimeM ethodHandle

Jan 30 '07 #1
7 10167
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
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.Threadin g;
using System.Diagnost ics;
using System.Reflecti on;
using System.Collecti ons;
using WebUtils;
using WebUtils.Databa ses;

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.Sc hedule
/// class. Then there are several fields and
methods you should override:
/// <code>
/// namespace ReportDaemon.Sc hedules {
/// /// &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>Call ed 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.AppSetti ngs.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.TimerCallb ack ), null, 0, Timeout.Infinit e );
}

/// <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 = startedExecutin g;
if( DateTime.MinVal ue != start ) {
return
DateTime.Now.Su btract( start );
}
return TimeSpan.Zero;
}
}
private DateTime startedExecutin g = DateTime.MinVal ue;

/// <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 {
startedExecutin g =
DateTime.Now;
if( isRunning ) {

EventLogger.Log Info( "Running " + Name );

timer.Change( (int)RunRate.To talMilliseconds , Timeout.Infinit e ); //
Set it to run again
Run();
errorCount = 0;
}
} catch( Exception e ) {
ReportDaemon.Lo gError( e );
if( ++errorCount == 3 ) {
throw new
Exception( "Due to excessive errors in the schedule " + Name + ", the
ReportDaemon is stopping itself." );
}
} finally {
startedExecutin g =
DateTime.MinVal ue;
}
}
}

/// <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 StartShuttingdo wn() {
isRunning = false;
}

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

if( !Monitor.TryEnt er( runOnce,
5000 ) ) {
EventLogger.Log Info( Name + "
appears to be blocked." );
}

timer.Dispose( shutdown );
if( !shutdown.WaitO ne( 2000, false ) )
{
EventLogger.Log Info( Name + "
failed to dispose properly." );
}
}
EventLogger.Log Info( "Disposed " + Name );
}
}
}

Jan 30 '07 #3
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.WaitForPendi ngFinalizers(), 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.goo glegroups.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.NullRefe renceException: 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.Componen tModel.Win32Exc eption: Invalid access to memory
location
at System.Diagnost ics.EventLog.Wr iteEvent(Int32 eventID, Int16
category, EventLogEntryTy pe type, String[] strings, Byte[] rawData)
at System.Diagnost ics.EventLog.Wr iteEntry(String message,
EventLogEntryTy pe type, Int32 eventID, Int16 category, Byte[] rawData)
at System.Diagnost ics.EventLog.Wr iteEntry(String message,
EventLogEntryTy pe type, Int32 eventID, Int16 category)
at System.Diagnost ics.EventLog.Wr iteEntry(String message,
EventLogEntryTy pe type, Int32 eventID)
at System.Diagnost ics.EventLog.Wr iteEntry(String message,
EventLogEntryTy pe type)
at ReportDaemon.Re portDaemon.LogE rror(Exception e) in e:\web\arch
telecom test\portal2_1\ reportdaemon\re portdaemon.cs:l ine 110
at ReportDaemon.Sc hedule.TimerCal lback(Object data) in e:\web\arch
telecom test\portal2_1\ reportdaemon\sc heduler.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.NullRefe renceException: Object reference not set to an instance
of an object.
at System.Data.Ole Db.DBPropSet.Wr itePropertySet( )
at System.Data.Ole Db.DBPropSet.Wr itePropertySet( Guid propertySet,
Int32 propertyCount)
at System.Data.Ole Db.OleDbCommand .CommandPropert ySets()
at System.Data.Ole Db.OleDbCommand .PropertyValueS etInternal()
at System.Data.Ole Db.OleDbCommand .InitializeComm and(CommandBeha vior
behavior, Boolean throwifnotsuppo rted)
at System.Data.Ole Db.OleDbCommand .ExecuteCommand (CommandBehavio r
behavior, Object& executeResult)
at
System.Data.Ole Db.OleDbCommand .ExecuteReaderI nternal(Command Behavior
behavior, String method)
at System.Data.Ole Db.OleDbCommand .ExecuteReader( CommandBehavior
behavior)
at
System.Data.Ole Db.OleDbCommand .System.Data.ID bCommand.Execut eReader(Com
mandBehavior behavior)
at System.Data.Com mon.DbDataAdapt er.FillFromComm and(Object data,
Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand
command, CommandBehavior behavior)
at System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet, Int32
startRecord, Int32 maxRecords, String srcTable, IDbCommand command,
CommandBehavior behavior)
at System.Data.Com mon.DbDataAdapt er.Fill(DataSet dataSet)
at WebUtils.Databa ses.StoredProce dure.GetDataSet (Boolean bValidate,
Boolean bRequireRows) in E:\web\Arch Telecom Test\Portal2_1\ WebUtils
\Databases\DBNG .cs:line 582
at WebUtils.Databa ses.StoredProce dure.GetDataSet (Boolean bValidate)
in E:\web\Arch Telecom Test\Portal2_1\ WebUtils\Databa ses\DBNG.cs:lin e
518
at WebUtils.Databa ses.StoredProce dure.GetDataTab le(Boolean
bValidate) in E:\web\Arch Telecom Test\Portal2_1\ WebUtils\Databa ses
\DBNG.cs:line 487
at
WebUtils.Databa ses.VSERV_DATAB ASES.IVRLOGDB.G etNextReportFor HTMLGenerat
ion() in E:\web\Arch Telecom Test\Portal2_1\ WebUtils\Databa ses\VSERV
\IVRLOGDB.cs:li ne 62
at ReportDaemon.Sc hedules.ReportG enerator.Run() in E:\web\Arch
Telecom Test\Portal2_1\ ReportDaemon\Sc hedules\ReportG enerator.cs:lin e
138
at ReportDaemon.Sc hedule.TimerCal lback(Object data) in e:\web\arch
telecom test\portal2_1\ reportdaemon\sc heduler.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.Exceptio n
- error {"Object reference not set to an instance of an object." }
System.Exceptio n
- [System.NullRefe renceException] {"Object reference not set to an
instance of an object." } System.NullRefe renceException
- System.SystemEx ception {"Object reference not set to an instance of
an object."} System.SystemEx ception
- System.Exceptio n {"Object reference not set to an instance of an
object." } System.Exceptio n
System.Object {System.NullRef erenceException } System.Object
_className null string
_COMPlusExcepti onCode -532459699 int
- _exceptionMetho d {System.Reflect ion.RuntimeMeth odInfo}
System.Reflecti on.MethodBase
+ [System.Reflecti on.RuntimeMetho dInfo]
{System.Reflect ion.RuntimeMeth odInfo}
System.Reflecti on.RuntimeMetho dInfo
+ System.Reflecti on.MemberInfo {System.Reflect ion.RuntimeMeth odInfo}
System.Reflecti on.MemberInfo
Attributes 129 System.Reflecti on.MethodAttrib utes
CallingConventi on 33 System.Reflecti on.CallingConve ntions
IsAbstract false bool
IsAssembly false bool
IsConstructor false bool
IsFamily false bool
IsFamilyAndAsse mbly false bool
IsFamilyOrAssem bly 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.Runtime MethodHandle} System.RuntimeM ethodHandle
_exceptionMetho dString null string
_helpURL null string
_HResult -2147467261 int
_innerException { } System.Exceptio n
_message "Object reference not set to an instance of an object."
string
_remoteStackInd ex 0 int
_remoteStackTra ceString null string
_source null string
+ _stackTrace {System.Array} System.Object
_stackTraceStri ng null string
_xcode -1073741819 int
_xptrs 78376988 int
HelpLink null string
HResult -2147467261 int
InnerException { } System.Exceptio n
Message "Object reference not set to an instance of an object."
string
Source <error: an exception of type: {System.NullRef erenceException }
occurredstring
StackTrace <error: an exception of type:
{System.NullRef erenceException } occurredstring
+ TargetSite {System.Reflect ion.RuntimeMeth odInfo}
System.Reflecti on.MethodBase
System.Object {System.NullRef erenceException } System.Object
_className null string
_COMPlusExcepti onCode -532459699 int
_exceptionMetho d <undefined valueSystem.Ref lection.MethodB ase
_exceptionMetho dString null string
_helpURL null string
_HResult -2147467261 int
_innerException { } System.Exceptio n
_message "Object reference not set to an instance of an object."
string
_remoteStackInd ex 0 int
_remoteStackTra ceString 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
_stackTraceStri ng null string
_xcode -1073741819 int
_xptrs 78376988 int
HelpLink null string
HResult -2147467261 int
InnerException { } System.Exceptio n
Message "Object reference not set to an instance of an object."
string
Source <error: an exception of type: {System.NullRef erenceException }
occurredstring
StackTrace <error: an exception of type:
{System.NullRef erenceException } occurredstring
- TargetSite {System.Reflect ion.RuntimeMeth odInfo}
System.Reflecti on.MethodBase
+ [System.Reflecti on.RuntimeMetho dInfo]
{System.Reflect ion.RuntimeMeth odInfo}
System.Reflecti on.RuntimeMetho dInfo
+ System.Reflecti on.MemberInfo {System.Reflect ion.RuntimeMeth odInfo}
System.Reflecti on.MemberInfo
Attributes 129 System.Reflecti on.MethodAttrib utes
CallingConventi on 33 System.Reflecti on.CallingConve ntions
IsAbstract false bool
IsAssembly false bool
IsConstructor false bool
IsFamily false bool
IsFamilyAndAsse mbly false bool
IsFamilyOrAssem bly 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.Runtime MethodHandle} System.RuntimeM ethodHandle

Jan 31 '07 #4
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.WaitForPendi ngFinalizers(), but I wonder if I am still not calling
it frequently enough.

Jan 31 '07 #5
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.goo glegroups.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.WaitForPendi ngFinalizers(), but I wonder if I am still not calling
it frequently enough.

Feb 1 '07 #6
"Laura T." <LT@NOWHERE.COM wrote in message news:uo******** ******@TK2MSFTN GP04.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 COMPlusExceptio nCode -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
I added the GC.WaitForPendi ngFinalizers() 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3682
by: Noa Garnett | last post by:
I'm developing on C++, using visual studio 6.0 with service pack 5. I have a memory corruption while debugging. Some of the variables I'm using are suddenly set to zero while progressing along the code. The specific location of the memory corruption depends on the names I give my local variables, on putting some of the codes in curly brackets - {}, and on having the watch window open. I already cleaned and re-built my project. Can anyone...
9
6865
by: prabhat143 | last post by:
Hi, I was recently asked to write a function in C that would detect if memory is corrupted. I had no clue about the solution but what I believe is that the solution is not complicated. Does anybody know how to write such a function? Regards, Prabhat
4
2432
by: indushekara | last post by:
Hi, We are having memory corruption in our application somewhere, unable to find out. one part of code we found that we are specifying wrong format specifier. Could anyone let me know if the following code may cause memory corruption. #include <stdio.h>
3
95103
by: Paminu | last post by:
I get this error after running my application for some time. What does it mean and what should I be looking for in my code?
4
2127
by: Harsha | last post by:
Hi All, There is some memory corruption in my application. It is due to the fact that it is multithreaded. Is this due to some missing mutex locking? Is there any way to find where it is crashing or where the corruption is occuring? I have the applications FATAL log. (it's on windows) I am not familiar with debugging core dumps and also since it is
4
2789
by: Tomassus | last post by:
Hi there, I have a problem with dynamic memory allocation. I know that it would have been easier to use vectors methods, but i want to know what i do here wrong. This is one of my methods in t_Item class - I use it to store Item Objects (which are classes too). xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx class t_Item { public:
14
3357
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using VS2005 and .net 2.0. I'm creating an application that has 3 forms. I want allow users to move forward and backward with the forms and retain the data users have entered. I thought I'll make the inactive forms invisible but this is creating a memory corruption problem when user close the form2 or form3 and not the formMain. My main form has a Next button which makes the main form invisible and starts a new form which I'll...
2
3786
by: Fredo | last post by:
First of all, I apologize for cross-posting. I posted this on the framework.interop group as well, but haven't received a response yet, so I thought I'd try here... I'm trying to write an app that perfroms some work using the CUDA SDK (for programming the nVidia GPU). One of the first methods I wrote is simply to query information about the CUDA devices (video cards).
0
8826
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6166
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.