exception from ResetSyncEvent

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

exception from ResetSyncEvent

Postby Azazaz » Sun Aug 07, 2016 7:05 pm

Lately, in the windows desktop application I'm developing, I've been getting an exception from ResetSyncEvent.

procedure ResetSyncEvent;
{$IF Defined(MSWINDOWS)}
begin
ResetEvent(SyncEvent);
end;

The debugger says it is attempting to access a null pointer.

The Call Stack doesn't reference any of my code, and I have not added any new threads or components to the project for quite a while. This just started happening a couple of weeks ago and only happens, seemingly at random, about once or twice a week when I'm full-on coding.

Anyone know what could be causing this? Or the best way to try to debug?
Azazaz
BCBJ Guru
BCBJ Guru
 
Posts: 105
Joined: Wed Sep 26, 2012 9:08 am

Re: exception from ResetSyncEvent

Postby rlebeau » Mon Aug 08, 2016 4:42 pm

Azazaz wrote:
Code: Select all
procedure ResetSyncEvent;
{$IF Defined(MSWINDOWS)}
begin
  ResetEvent(SyncEvent);
end;


The debugger says it is attempting to access a null pointer.


What *EXACTLY* is the debugger saying? And what is the code actually doing if you dismiss the debugger?

What you showed is Delphi code, but this is a C++Builder forum. Are you calling ResetSyncEvent() in C++ code? Where are ResetSyncEvent() and SyncEvent actually defined?

I am assuming that ResetEvent() is the Win32 API ResetEvent(), is that right? Is SyncEvent a THandle? Passing a nil THandle to the Win32 API ResetEvent() does not cause a crash, it simply fails with an ERROR_INVALID_HANDLE error. Where does the debugger say the actual error is occurring?

Azazaz wrote:The Call Stack doesn't reference any of my code


What *DOES* it reference?

Azazaz wrote:I have not added any new threads or components to the project for quite a while. This just started happening a couple of weeks ago and only happens, seemingly at random, about once or twice a week when I'm full-on coding.


Is the error happening at *design-time*, *compile-time*, or *run-time*?

Azazaz wrote:Anyone know what could be causing this?


There is not enough information here to diagnose that.
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1403
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: exception from ResetSyncEvent

Postby Azazaz » Tue Aug 09, 2016 2:39 am

Sorry. I'll try to answer your questions.

The reason the code I supplied is Pascal is because that is where the exception is occurring, i.e., it is an exception occurring at line 14208 in

\Program Files (x86)\Embarcadero\Studio\16.0\source\rtl\common\System.Classes.pas

I don't have the exact message as I didn't save it last time, but it seems to be pretty much the standard message one gets when trying to access a null pointer.

It happens within the IDE after the application has been launched and while the application is running.

As for whether the application throws an exception outside the IDE, I haven't seen it. But since the exception is fairly intermittent, it's hard to say for sure since I don't run the application outside of the IDE very often.

I have not been able (so far) to recognize any particular pattern as to when it occurs, i.e., it does not seem related to what I am doing from a user's perspective in the application, although it could be some code of mine (or one of the components I use) I guess that only gets executed from time to time.

When I dismiss the Debugger, things continue on normally, as far as I can tell, i.e., the application within the IDE continues to operate as expected.

Hope this helps. If you need more information, I will try to provide it. Thanks for your help.
Azazaz
BCBJ Guru
BCBJ Guru
 
Posts: 105
Joined: Wed Sep 26, 2012 9:08 am

Re: exception from ResetSyncEvent

Postby rlebeau » Tue Aug 09, 2016 7:24 pm

Azazaz wrote:The reason the code I supplied is Pascal is because that is where the exception is occurring, i.e., it is an exception occurring at line 14208 in

\Program Files (x86)\Embarcadero\Studio\16.0\source\rtl\common\System.Classes.pas


Next time, please specify the actual product version you are using. The 16.0 folder is in XE8.

You and I must be using different versions of XE8, because in my copy, line 14208 is not inside of ResetSyncEvent(). It is inside of CheckSynchronize() instead (which does call ResetSyncEvent()), when an exception has been raised in a queued method and it is checking if ApplicationHandleException is assigned to handle the exception:

Code: Select all
try
  if Assigned(SyncProc.SyncRec.FMethod) then
    SyncProc.SyncRec.FMethod()
  else if Assigned(SyncProc.SyncRec.FProcedure) then
  SyncProc.SyncRec.FProcedure();
except
  if not SyncProc.Queued then
    SyncProc.SyncRec.FSynchronizeException := AcquireExceptionObject
  else if Assigned(ApplicationHandleException) then // <-- line 14208
    ApplicationHandleException(SyncProc.SyncRec.FThread);
end;


Azazaz wrote:I don't have the exact message as I didn't save it last time


Then I can't really help you. Please save it when it happens again.

Azazaz wrote:I have not been able (so far) to recognize any particular pattern as to when it occurs, i.e., it does not seem related to what I am doing from a user's perspective in the application, although it could be some code of mine (or one of the components I use) I guess that only gets executed from time to time.


CheckSynchronize() does get called at random times, such as when the main UI thread is finished processing messages and goes idle. CheckSynchronize() is called right after the TApplication.OnIdle event is fired.

Azazaz wrote:When I dismiss the Debugger, things continue on normally, as far as I can tell, i.e., the application within the IDE continues to operate as expected.


Well, then it is not a fatal exception, it must be getting caught somewhere.
Remy Lebeau (TeamB)
Lebeau Software
User avatar
rlebeau
BCBJ Author
BCBJ Author
 
Posts: 1403
Joined: Wed Jun 01, 2005 3:21 am
Location: California, USA

Re: exception from ResetSyncEvent

Postby Azazaz » Sat Aug 13, 2016 3:32 pm

Okay.

Sorry about not providing enough info. I know better and usually do better, but I guess I was tired or not thinking straight or something -- not for the first time.

Anyhow, thanks.
Azazaz
BCBJ Guru
BCBJ Guru
 
Posts: 105
Joined: Wed Sep 26, 2012 9:08 am


Return to Technical

Who is online

Users browsing this forum: Google [Bot] and 5 guests

cron