Alaska Software Inc. - Incorrect thread errors
Username: Password:
AuthorTopic: Incorrect thread errors
James Loughner Incorrect thread errors
on Mon, 24 Nov 2008 13:59:59 -0500
Got these errors today all seem to have been caused by an event being
handled in the wrong thread. My first thought has been a memory leak so
I added memory reporting to the error logs. But it seems that memory
usage is reasonable. All are from the same machine but not the normal
problem machine at this site.

All the methods being called are created and normally run in their own
thread and should not be processed by the main event loop. The actually
errors are because the DBFs referenced in the methods are opened in the
worker thread but not in the main. Thus the  "Unknown/Invalid symbol for
alias" error message.

Errors 2 and 3 are from my shadow button class and it uses owner draw
also the menu system is owner draw.

But the first error is simply a validation via killinputfocus. no owner
draw directly involved.


These are random and not reproducible.

Any ideas??

Jim

------------------------------------------------------------------------------
ERRORMESSAGE PROTOCOL from "M:\MPM.exe" Date: 11/24/2008 08:38:33AM

MPM VersionVer 2.0.2183



Log-Filename  Xpperror.log

Xbase++ Version     : Xbase++ (R) Version 1.90.331

------------------------------------------------------------------------------
------------------------------------------------------------------------------
Database path       :

------------------------------------------------------------------------------
Operating System      : Windows XP 05.01 Build 02600 Service Pack 3

------------------------------------------------------------------------------
oError:args         :

oError:canDefault   : N

oError:canRetry     : N

oError:canSubstitute: N

oError:cargo        : NIL

oError:description  : Unknown/Invalid symbol for alias

oError:filename     :

oError:genCode      :         66

oError:operation    : ->

oError:osCode       :          0

oError:severity     :          2

oError:subCode      :       8022

oError:subSystem    : BASE

oError:thread       :          1

oError:tries        :          0



Company             : Horse Trader

Computername        : BILLING02

Log-In Name         : Administrator

------------------------------------------------------------------------------
virtual memory used          :     808851

virtual memory size          :    1259520

RAM Avialable                :     237568

RAM Total                    :     523264



available to the process     :     811524

currently used by the process:       2673

------------------------------------------------------------------------------
CALLSTACK:

------------------------------------------------------------------------------
Called from ADCL_SELECTADVTSR:CHECKSEARCH(764)

Called from (B)SELECTADVERTISER:INIT(45)

Called from SLEPIC:KILLINPUTFOCUS(693)

Called from MAIN(179)



------------------------------------------------------------------------------
WORKAREA STATUS:

------------------------------------------------------------------------------
 Area Alias         Record     Index        Order      Eof Bof Del Found

------------------------------------------------------------------------------
   1  USERS          20/30                             No  No  No  Yes

   2  HOLIDAYS        1/0      holidays.CDX HOLIDAYS   Yes Yes No  No

*  3  APPT            1/0      Apptuser.CDX APPTUSER   Yes Yes No  No





------------------------------------------------------------------------------
ERRORMESSAGE PROTOCOL from "M:\MPM.exe" Date: 11/24/2008 09:19:33AM

MPM VersionVer 2.0.2183



Log-Filename  Xpperror.log

Xbase++ Version     : Xbase++ (R) Version 1.90.331

------------------------------------------------------------------------------
------------------------------------------------------------------------------
Database path       :

------------------------------------------------------------------------------
Operating System      : Windows XP 05.01 Build 02600 Service Pack 3

------------------------------------------------------------------------------
oError:args         :

oError:canDefault   : N

oError:canRetry     : N

oError:canSubstitute: N

oError:cargo        : NIL

oError:description  : Unknown/Invalid symbol for alias

oError:filename     :

oError:genCode      :         66

oError:operation    : ->

oError:osCode       :          0

oError:severity     :          2

oError:subCode      :       8022

oError:subSystem    : BASE

oError:thread       :          1

oError:tries        :          0



Company             : Horse Trader

Computername        : BILLING02

Log-In Name         : Administrator

------------------------------------------------------------------------------
virtual memory used          :     808657

virtual memory size          :    1259520

RAM Avialable                :     240640

RAM Total                    :     523264



available to the process     :     811524

currently used by the process:       2867

------------------------------------------------------------------------------
CALLSTACK:

------------------------------------------------------------------------------
Called from ADCL_SELECTADVTSR:CONTINUE_ON(868)

Called from (B)ADCL_SELECTADVTSR:INIT(633)

Called from SHADOWBUTTON:LBUP(464)

Called from SHADOWBUTTON:HANDLEEVENT(184)

Called from MAIN(179)



------------------------------------------------------------------------------
WORKAREA STATUS:

------------------------------------------------------------------------------
 Area Alias         Record     Index        Order      Eof Bof Del Found

------------------------------------------------------------------------------
   1  USERS          20/30                             No  No  No  Yes

   2  HOLIDAYS        1/0      holidays.CDX HOLIDAYS   Yes Yes No  No

*  3  APPT            1/0      Apptuser.CDX APPTUSER   Yes Yes No  No



------------------------------------------------------------------------------
ERRORMESSAGE PROTOCOL from "M:\MPM.exe" Date: 11/24/2008 09:20:26AM

MPM VersionVer 2.0.2183



Log-Filename  Xpperror.log

Xbase++ Version     : Xbase++ (R) Version 1.90.331

------------------------------------------------------------------------------
------------------------------------------------------------------------------
Database path       :

------------------------------------------------------------------------------
Operating System      : Windows XP 05.01 Build 02600 Service Pack 3

------------------------------------------------------------------------------
oError:args         :

oError:canDefault   : N

oError:canRetry     : N

oError:canSubstitute: N

oError:cargo        : NIL

oError:description  : Unknown/Invalid symbol for alias

oError:filename     :

oError:genCode      :         66

oError:operation    : ->

oError:osCode       :          0

oError:severity     :          2

oError:subCode      :       8022

oError:subSystem    : BASE

oError:thread       :          1

oError:tries        :          0



Company             : Horse Trader

Computername        : BILLING02

Log-In Name         : Administrator

------------------------------------------------------------------------------
virtual memory used          :     808665

virtual memory size          :    1259520

RAM Avialable                :     239616

RAM Total                    :     523264



available to the process     :     811524

currently used by the process:       2859

------------------------------------------------------------------------------
CALLSTACK:

------------------------------------------------------------------------------
Called from SELECTDISPLAYADVERTISER:STARTEDIT(1050)

Called from (B)SELECTDISPLAYADVERTISER:INIT(928)

Called from SHADOWBUTTON:LBUP(464)

Called from SHADOWBUTTON:HANDLEEVENT(184)

Called from MAIN(179)



------------------------------------------------------------------------------
WORKAREA STATUS:

------------------------------------------------------------------------------
 Area Alias         Record     Index        Order      Eof Bof Del Found

------------------------------------------------------------------------------
   1  USERS          20/30                             No  No  No  Yes

   2  HOLIDAYS        1/0      holidays.CDX HOLIDAYS   Yes Yes No  No

*  3  APPT            1/0      Apptuser.CDX APPTUSER   Yes Yes No  No
Clifford Wiernik Re: Incorrect thread errors
on Wed, 26 Nov 2008 19:31:36 -0600
James Loughner wrote:
> Got these errors today all seem to have been caused by an event being
> handled in the wrong thread. My first thought has been a memory leak so
> I added memory reporting to the error logs. But it seems that memory
> usage is reasonable. All are from the same machine but not the normal
> problem machine at this site.
> 
> All the methods being called are created and normally run in their own
> thread and should not be processed by the main event loop. The actually
> errors are because the DBFs referenced in the methods are opened in the
> worker thread but not in the main. Thus the  "Unknown/Invalid symbol for
> alias" error message.
> 
> Errors 2 and 3 are from my shadow button class and it uses owner draw
> also the menu system is owner draw.
> 
> But the first error is simply a validation via killinputfocus. no owner
> draw directly involved.
> 
> 
> These are random and not reproducible.
> 
> Any ideas??
> 
> Jim
> 
> ------------------------------------------------------------------------------
> ERRORMESSAGE PROTOCOL from "M:\MPM.exe" Date: 11/24/2008 08:38:33AM
> 
> MPM VersionVer 2.0.2183
> 
> 
> 
> Log-Filename  Xpperror.log
> 
> Xbase++ Version     : Xbase++ (R) Version 1.90.331
> 
> ------------------------------------------------------------------------------
> ------------------------------------------------------------------------------
> Database path       :
> 
> ------------------------------------------------------------------------------
> Operating System      : Windows XP 05.01 Build 02600 Service Pack 3
> 
> ------------------------------------------------------------------------------
> oError:args         :
> 
> oError:canDefault   : N
> 
> oError:canRetry     : N
> 
> oError:canSubstitute: N
> 
> oError:cargo        : NIL
> 
> oError:description  : Unknown/Invalid symbol for alias
> 
> oError:filename     :
> 
> oError:genCode      :         66
> 
> oError:operation    : ->
> 
> oError:osCode       :          0
> 
> oError:severity     :          2
> 
> oError:subCode      :       8022
> 
> oError:subSystem    : BASE
> 
> oError:thread       :          1
> 
> oError:tries        :          0
> 
> 
> 
> Company             : Horse Trader
> 
> Computername        : BILLING02
> 
> Log-In Name         : Administrator
> 
> ------------------------------------------------------------------------------
> virtual memory used          :     808851
> 
> virtual memory size          :    1259520
> 
> RAM Avialable                :     237568
> 
> RAM Total                    :     523264
> 
> 
> 
> available to the process     :     811524
> 
> currently used by the process:       2673
> 
> ------------------------------------------------------------------------------
> CALLSTACK:
> 
> ------------------------------------------------------------------------------
> Called from ADCL_SELECTADVTSR:CHECKSEARCH(764)
> 
> Called from (B)SELECTADVERTISER:INIT(45)
> 
> Called from SLEPIC:KILLINPUTFOCUS(693)
> 
> Called from MAIN(179)
> 
> 
> 
> ------------------------------------------------------------------------------
> WORKAREA STATUS:
> 
> ------------------------------------------------------------------------------
>  Area Alias         Record     Index        Order      Eof Bof Del Found
> 
> ------------------------------------------------------------------------------
>    1  USERS          20/30                             No  No  No  Yes
> 
>    2  HOLIDAYS        1/0      holidays.CDX HOLIDAYS   Yes Yes No  No
> 
> *  3  APPT            1/0      Apptuser.CDX APPTUSER   Yes Yes No  No
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> ERRORMESSAGE PROTOCOL from "M:\MPM.exe" Date: 11/24/2008 09:19:33AM
> 
> MPM VersionVer 2.0.2183
> 
> 
> 
> Log-Filename  Xpperror.log
> 
> Xbase++ Version     : Xbase++ (R) Version 1.90.331
> 
> ------------------------------------------------------------------------------
> ------------------------------------------------------------------------------
> Database path       :
> 
> ------------------------------------------------------------------------------
> Operating System      : Windows XP 05.01 Build 02600 Service Pack 3
> 
> ------------------------------------------------------------------------------
> oError:args         :
> 
> oError:canDefault   : N
> 
> oError:canRetry     : N
> 
> oError:canSubstitute: N
> 
> oError:cargo        : NIL
> 
> oError:description  : Unknown/Invalid symbol for alias
> 
> oError:filename     :
> 
> oError:genCode      :         66
> 
> oError:operation    : ->
> 
> oError:osCode       :          0
> 
> oError:severity     :          2
> 
> oError:subCode      :       8022
> 
> oError:subSystem    : BASE
> 
> oError:thread       :          1
> 
> oError:tries        :          0
> 
> 
> 
> Company             : Horse Trader
> 
> Computername        : BILLING02
> 
> Log-In Name         : Administrator
> 
> ------------------------------------------------------------------------------
> virtual memory used          :     808657
> 
> virtual memory size          :    1259520
> 
> RAM Avialable                :     240640
> 
> RAM Total                    :     523264
> 
> 
> 
> available to the process     :     811524
> 
> currently used by the process:       2867
> 
> ------------------------------------------------------------------------------
> CALLSTACK:
> 
> ------------------------------------------------------------------------------
> Called from ADCL_SELECTADVTSR:CONTINUE_ON(868)
> 
> Called from (B)ADCL_SELECTADVTSR:INIT(633)
> 
> Called from SHADOWBUTTON:LBUP(464)
> 
> Called from SHADOWBUTTON:HANDLEEVENT(184)
> 
> Called from MAIN(179)
> 
> 
> 
> ------------------------------------------------------------------------------
> WORKAREA STATUS:
> 
> ------------------------------------------------------------------------------
>  Area Alias         Record     Index        Order      Eof Bof Del Found
> 
> ------------------------------------------------------------------------------
>    1  USERS          20/30                             No  No  No  Yes
> 
>    2  HOLIDAYS        1/0      holidays.CDX HOLIDAYS   Yes Yes No  No
> 
> *  3  APPT            1/0      Apptuser.CDX APPTUSER   Yes Yes No  No
> 
> 
> 
> ------------------------------------------------------------------------------
> ERRORMESSAGE PROTOCOL from "M:\MPM.exe" Date: 11/24/2008 09:20:26AM
> 
> MPM VersionVer 2.0.2183
> 
> 
> 
> Log-Filename  Xpperror.log
> 
> Xbase++ Version     : Xbase++ (R) Version 1.90.331
> 
> ------------------------------------------------------------------------------
> ------------------------------------------------------------------------------
> Database path       :
> 
> ------------------------------------------------------------------------------
> Operating System      : Windows XP 05.01 Build 02600 Service Pack 3
> 
> ------------------------------------------------------------------------------
> oError:args         :
> 
> oError:canDefault   : N
> 
> oError:canRetry     : N
> 
> oError:canSubstitute: N
> 
> oError:cargo        : NIL
> 
> oError:description  : Unknown/Invalid symbol for alias
> 
> oError:filename     :
> 
> oError:genCode      :         66
> 
> oError:operation    : ->
> 
> oError:osCode       :          0
> 
> oError:severity     :          2
> 
> oError:subCode      :       8022
> 
> oError:subSystem    : BASE
> 
> oError:thread       :          1
> 
> oError:tries        :          0
> 
> 
> 
> Company             : Horse Trader
> 
> Computername        : BILLING02
> 
> Log-In Name         : Administrator
> 
> ------------------------------------------------------------------------------
> virtual memory used          :     808665
> 
> virtual memory size          :    1259520
> 
> RAM Avialable                :     239616
> 
> RAM Total                    :     523264
> 
> 
> 
> available to the process     :     811524
> 
> currently used by the process:       2859
> 
> ------------------------------------------------------------------------------
> CALLSTACK:
> 
> ------------------------------------------------------------------------------
> Called from SELECTDISPLAYADVERTISER:STARTEDIT(1050)
> 
> Called from (B)SELECTDISPLAYADVERTISER:INIT(928)
> 
> Called from SHADOWBUTTON:LBUP(464)
> 
> Called from SHADOWBUTTON:HANDLEEVENT(184)
> 
> Called from MAIN(179)
> 
> 
> 
> ------------------------------------------------------------------------------
> WORKAREA STATUS:
> 
> ------------------------------------------------------------------------------
>  Area Alias         Record     Index        Order      Eof Bof Del Found
> 
> ------------------------------------------------------------------------------
>    1  USERS          20/30                             No  No  No  Yes
> 
>    2  HOLIDAYS        1/0      holidays.CDX HOLIDAYS   Yes Yes No  No
> 
> *  3  APPT            1/0      Apptuser.CDX APPTUSER   Yes Yes No  No
> 
It is entirely possible for this to happen randomly.  I don't know how 
your specific code is written but I can explain my circumstances with a 
similar situation in Express++.  Our application has many dialogs open, 
each running in their own thread, that handle the different type of 
customer finance accounts, related credit application and dealer 
maintenance screens.  The users go back and forth via a variety of 
manners, Ctrl-F6, Alt-W, clicking on screen, etc.

Also, the application typically sits in a data entry field (account #) 
that has a valid clause that formats the data entry upon exit of the 
field and retrieves and display the account.

Some of the methods of changing between dialogs cause the data entry 
field to be exited (similar to pressing esc in the dialog) which causes 
Express++'s _processhotkey function to do various items of cleanup.  At 
the top of that function is the statement oAppFocus := setappfocus() 
which determines what object was in focus and is used during the 
processing as to destination object of some code snippet.

In actual production, but not recreatable, what happens is due to system 
process load and resulting latency, the dialog context switch to the new 
occurs before the code that is processed upon exit of the previous in 
focus dialog.  Thus, the new dialog is on top of the old dialog and the 
new dialog has its setappfocus() stored to oAppFocus.  oAppFocus is 
however being processed in the old dialog thread and when it is used in 
the _processhotkey code, you have oAppFocus point to an object in the 
new thread but the variables being processed in the old thread are in 2 
different threads.  My issues showed up in a private variable (which are 
local thread visibility only) or if I change the variable to a local, it 
just moved to a different portion of the code where it pointed to a 
database field, for which the alias was not visible due it being from 
the other thread.

I could not recreate the problem in the program by testing because I 
could not recreate the latency issue.  However, it was easy to mimic the 
behavior by putting a timeout process in the old dialog that posted an 
ESC to the old dialog, trigger the call to _processhotkey() from the 
valid clause. Prior to the timeout I put the new dialog on top of the 
old dialog, so that SetAppfocus() now pointed to the new dialog's 
thread.  This value was passed to the _processhotkey() call in the old 
dialog when the timeout was trigger, demonstrating what happened to the 
same identical runtime error each and every time.

Is it possible that you have some type of SetAppFocus() call in your 
method processing dialog events that could be similar to this.  I don't 
know but I know this can happen.

Cliff.