Exception in Adxwsbcls.TadxTheme.InitThemeColor

Add-in Express™ Support Service
That's what is more important than anything else

Exception in Adxwsbcls.TadxTheme.InitThemeColor
 
Andrei Smolin


Add-in Express team


Posts: 18421
Joined: 2006-05-11
Hello Tim,

Could you please provide some info for us to create a test add-in? Or, you can create a test add-in for us to reproduce the issue.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 31 Aug, 2018 06:54:28 Top
Tim Smet




Posts: 37
Joined: 2015-10-06
Andrei,

I can not give you a test addin as i have not been able to reproduce this exception nor the word 2016 crashing issues after using latest addin express on any of the pc's in the office. It are all clients that are calling us that have this new addin version installed one where we had cought this exception using exceptional magic and a whole lot saying their word crashes and reopens randomly. Reverting to our previous addin version which is build against older addin express does not exhibit these problems.


We have about 10 offices so lets say 30 pc's where the problem happens 3-4 times a day (eventlog is filled with word crashing entries ever since they had gotten the new addin version). The only info i have as said before is data from eventlogs (about the word 2016 crashing problem) and that stacktrace i posted initially about this exception occuring which Ronald had happen in outlook as well (with us it's in word).

Supplying our addin itselve won't do any good as you need the rest of our software to make it all work and that's not possible the addin won't run without it, but basically our addin does the following:
- it has 1 taskpane on the right of word document that only becomes visible at certain conditions (when we find certain data in document variables and executes macro's and replaces text based on bookmarks that got added in the documents.
- it has a system to define (using our configuring program) a set of icons as well as related macro's to execute when these icons are clicked in the ribbon
- a few static ribbon buttons to save or open documents directly to folder locations from our (external) program

and that's about it, it does nothing in the background but people having the problems did say they had the crashes happen while they were not in front of their pc's. (possibly due to some program or windows sending around wm_messages)

I'm not at work today so i'll try to reproduce it on monday by spamming those WM_MEssages around using postmessage & HWND_BROADCAST to see if it triggers the problem on any of my pc's in the office.

I wish i could provide a test addin or more information but that's basically all i know at the moment myselve as i can not reproduce. Except for the things ronald provided which does give some insight as where it might happen (well at least this exception since i'm not sure the word 2016 crashing thing is related)

I will probably add a try except statement in the same location as he did and install it with a certain office that had the problem to see if it fixes the word crashing (and thus know it's related to the same exception / bug or if it's another problem)

if i'm able to reproduce it using our addin on monday i'll try to create a simplified version to trigger the problem
Posted 31 Aug, 2018 09:28:44 Top
Tim Smet




Posts: 37
Joined: 2015-10-06
Hello Andrei,

I have been testing whole day .. and managed to reproduce only once to get the exception "Adxwsbcls.TadxTheme.InitThemeColor" . However it seems you can also get exception with a "call to and os function failed exception" which happens more frequently during my stress testing.

So the problem is with the WNDPROC's that call themechanged either in TadxThemeChanged.WndProc as Ronald already found out with this code:
User added an image

This first error can happen if you got multiple word documents open with your taskpane visible for some windows and for some not when it receives a WM_MESSAGE that triggers in the code in the wndproc while the document window is closing / objects being freed.

I test by creating a simple delphi application that does a postmessage every second of WM_SYSCOLORCHANGE in a loop since you can't actually know when that message arrives and it was hard to trigger so that's why i spam this message around every second using HWND_BROADCAST

if the message arrives while you are closing word windows and thus freeing taskpanes and TadxThemeChanged object it is possible that in TadxTheme.Refresh FThemeMSO is nil and themecolorindex is set to tmunknown. In that case initthemecolor is called with parameter -1 and Themecolor property is nil causing the access violation.

I don't know under which circumstances clients can get this but we have clients getting this error under normal conditions / word usuage without me spamming WM_SYSCOLORCHANGE around to trigger the problem. Ronald also had an example in outlook how you can trigger it in some cases.

See stacktrace here:
User added an image

for the a call to an os function failed it happens with TadxForm.DoThemeChanged more specifically when requesting the handle property it will try to recreate the window and fails. Did not check if it came from some wndproc or not
User added an image

In the zip file in the bottom i included example addin + my program to spam WM_SYSCOLORCHANGE around to trigger the problem during closing of multiple open word documents while the message is arriving and closing those word documents while the taskpane is visible (if not visible it does not happen)

This error i can easily reproduce and happens most of the time, I did not succeed in triggering the initthemecolor exception in example addin only with our adding but i'm guessing it depends when the WM_messages arrive to trigger the problems and i gave up testing eventually as it's time consuming.

Included in this zip file here i added the following:
- bug stacktrace Inittheme color exception (FThemecolor = nil).PNG screenshot showing initthemecolor exception in ide while debugging (i'm sorry i was not recording while it happend)
- A call to os function failed.avi video to show how to trigger "a call to an os function failed" exception. I used the same steps to also get the inittheme color exception but its hard to reproduce because timing issues / WM_MESSAGES needing to arrive at the exact right time so really hard to reproduce
- WND_MESSAGE Broacast spam: simple program to spam WM_SYSCOLORCHANGE in a loop
- addin express test: test addin that show taskpane for addin with per document option to show or hide the taskpane


Unfortunaty i'm not sure if the word crashing problem is related to this problem, as i could not reproduce this at all on my pc's and if i managed to let the exception sipple through to word and word crashed it displayed 0xc0000005 as exception code (which is access violation) and not 0x0eedfade which is indicator for a delphi exception somewhere (possibly in a thread but i'm not sure) i have to diagnose more.

Currently we reverted to previous addin / addin express version as the current version introduce too much problems and word crashes with our clients. Error which i can not reproduce under normal circumstances, without stress testing with WM_SYSCOLORCHANGE spam

edit: in WND_MESSAGE Broadcast spam, you need to remove DcsCtrls from unit8 or it won't compile, i accidently added that unit or it got auto added from our (own) controls. It should compile without or be easily recreated looking at other code i do it's basically broadcasting WM_MESSAGES around using postmessage every second. To try and trigger the problems because it's timing related when the messages arrive
Posted 03 Sep, 2018 10:04:02 Top
Andrei Smolin


Add-in Express team


Posts: 18421
Joined: 2006-05-11
Hello Tim,

Thank you very much!

Could you please check if the following code line added to the very beginning of the InitThemeColor method works:
if not Assigned(FThemeColor) then exit;

It should prevent the exception. What is strange, we didn't modify this code area long, long ago. We suppose there's some other reason that influences this behavior.

Thank you!

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 03 Sep, 2018 10:49:02 Top
Tim Smet




Posts: 37
Joined: 2015-10-06
Hi Andrei,

Adding that statement should indeed fix this error but it won't fix the a "call to an os function failed exception" . I'll probably add a try / except statement where it gets the handle to prevent the exception going all the way up into word.

Any program (but usually windows in control panel / settings / program installers) can broadcast WM_SYSCOLORCHANGE / WM_SETTINGCHANGE around and with the right timing / right circumstances this error can also happen (in theory) but it will probably happen less.

About FThemeColor being nil and probably causing the exception in topic title maybe in word / office things got changed in a certain build where either WM_SYSCOLORCHANGE or WM_SETTINGCHANGE or WM_MSO_BROADCASTCHANGE (my guess is the last one with the extra conditions as it's used internally) gets send around more often or from other locations / circumstances.

I'll create a test addin to see if the word (2016) crashing problem with 0x0eedfade exception code in windows eventlogs (indicating delphi exception) is also fixed after that, i think it's another problem as i could not reproduce using WM_MESSAGE spam and got a diffrent exception code (0xC0000005 indicating access violation) in windows eventlogs


0x0eedfade could be an unhandled Delphi exception propagated outside of a Delphi process. If the problem only exists when linking in the Dialogs unit it's possible that its initialization, or initialization of any unit it depends on, raises an exception which is not handled and escapes out of your Delphi process.

source

i think this can happen if some thread gets an unhandled exception in it's exec function and perhaps in other circumstances causing word to crash

I'll keep you posted and perhaps start a diffrent thread for that problem as initially this topic was about the initthemecolor problem
Posted 03 Sep, 2018 12:30:23 Top
Andrei Smolin


Add-in Express team


Posts: 18421
Joined: 2006-05-11
Thank you very much!

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 06 Sep, 2018 05:45:07 Top
GKoehn




Posts: 39
Joined: 2009-03-23
We are experiencing the same InitThemeColor issue in Outlook 2016.

This is Add-in Express adxVersion: string = '9.0.1650'; found in adxAddIn.pas.

Here is a madExcept trace...

date/time          : 2018-09-18, 10:03:47, 649ms

exception message  : Access violation at address 2316F19E in module 'OrionProductivityPackOutlookAddin.dll'. Read of address 000000A4.

main thread ($1dd0):
adxWSbcls      12057  +7 TadxTheme.InitThemeColor
adxWSbcls      22702  +1 TadxOLContainerPane2013.InitThemeColor
adxWSbcls      23963  +1 TadxOLContainerPane2016.InitThemeColor
adxWSbcls      12424  +2 TadxTheme.SetThemeColorIndex
adxWSbcls      12444 +13 TadxTheme.Refresh
adxWSbcls      12014  +1 TadxTheme.DoThemeChanged
adxWSbcls       6413  +1 TadxContainerPane.DoThemeChanged
adxWSbcls      14557  +4 TadxThemeChanged.WndProc
Vcl.Controls             TWinControl.MainWndProc
System.Classes           StdWndProc   

modules:
000e0000 OUTLOOK.EXE              16.0.10730.20102    C:Program Files (x86)Microsoft Office
ootOffice16
02600000 OSFSHARED.DLL            16.0.10730.20102    C:Program Files (x86)Microsoft Office
ootOffice16
02680000 OSFUI.DLL                16.0.10730.20088    C:Program Files (x86)Microsoft Office
ootOffice16
04460000 SFC.DLL                  10.0.17134.1        C:WINDOWSSystem32
0aed0000 OUTLLIBR.DLL             16.0.10730.20030    C:Program Files (x86)Microsoft Office
ootOffice16C3
0f900000 mapir.dll                16.0.10730.20030    C:Program Files (x86)Microsoft OfficeRootOffice16C3



Also have this trace from a bit later...

date/time          : 2018-09-18, 10:04:02, 400ms

exception message  : Access violation at address 231C6E24 in module 'OrionProductivityPackOutlookAddin.dll'. Read of address 00000018.

main thread ($1dd0):
231c6e24 +00090 OrionProductivityPackOutlookAddin.dll adxolFormsManager 17880  +12 TadxOlForm.UpdateCTPParam
2316655a +00036 OrionProductivityPackOutlookAddin.dll adxWSbcls          8492   +4 TadxForm.DoThemeChanged
2316ef68 +0001c OrionProductivityPackOutlookAddin.dll adxWSbcls         12016   +3 TadxTheme.DoThemeChanged
23161fa5 +00005 OrionProductivityPackOutlookAddin.dll adxWSbcls          6413   +1 TadxContainerPane.DoThemeChanged
23175b58 +0003c OrionProductivityPackOutlookAddin.dll adxWSbcls         14557   +4 TadxThemeChanged.WndProc
22d074b8 +0002c OrionProductivityPackOutlookAddin.dll Vcl.Controls                 TWinControl.MainWndProc
22bce6a8 +00014 OrionProductivityPackOutlookAddin.dll System.Classes               StdWndProc
22b15f43 +0004b OrionProductivityPackOutlookAddin.dll madExcept                    TIMESettings.GetPropBool
7733c6cb +0004b ntdll.dll                                                          KiUserCallbackDispatcher
73d62b3a +0000a win32u.dll                                                         NtUserGetMessage
7466a79a +0002a USER32.dll                                                         GetMessageW
22b3405b +002f7 OrionProductivityPackOutlookAddin.dll madExcept                    HandleException
22b3c8ea +0003a OrionProductivityPackOutlookAddin.dll madExcept                    InterceptAHandleExcept
22d074f3 +00067 OrionProductivityPackOutlookAddin.dll Vcl.Controls                 TWinControl.MainWndProc
7733c711 +00021 ntdll.dll                                                          KiUserExceptionDispatcher
7733c6cb +0004b ntdll.dll                                                          KiUserCallbackDispatcher
7468390d +1912d USER32.dll                                                         CallNextHookEx
2316e99b +003df OrionProductivityPackOutlookAddin.dll adxWSbcls         11950 +103 TadxOLMessageHook.MessageHookProc
23170364 +00014 OrionProductivityPackOutlookAddin.dll adxWSbcls         12424   +2 TadxTheme.SetThemeColorIndex
231703ec +00080 OrionProductivityPackOutlookAddin.dll adxWSbcls         12444  +13 TadxTheme.Refresh
2316ef51 +00005 OrionProductivityPackOutlookAddin.dll adxWSbcls         12014   +1 TadxTheme.DoThemeChanged
23161fa5 +00005 OrionProductivityPackOutlookAddin.dll adxWSbcls          6413   +1 TadxContainerPane.DoThemeChanged
23175b58 +0003c OrionProductivityPackOutlookAddin.dll adxWSbcls         14557   +4 TadxThemeChanged.WndProc
22d074b8 +0002c OrionProductivityPackOutlookAddin.dll Vcl.Controls                 TWinControl.MainWndProc
22bce6a8 +00014 OrionProductivityPackOutlookAddin.dll System.Classes               StdWndProc
7733c6cb +0004b ntdll.dll                                                          KiUserCallbackDispatcher
74668fef +0012f USER32.dll                                                         PeekMessageW
76ec8482 +00022 KERNEL32.DLL                                                       BaseThreadInitThunk

main thread ($1dd0), inner exception level 1:
>> EAccessViolation, Access violation at address 231C6E24 in module 'OrionProductivityPackOutlookAddin.dll'. Read of address 00000018
231c6e24 +00090 OrionProductivityPackOutlookAddin.dll adxolFormsManager 17880  +12 TadxOlForm.UpdateCTPParam
2316655a +00036 OrionProductivityPackOutlookAddin.dll adxWSbcls          8492   +4 TadxForm.DoThemeChanged
2316ef68 +0001c OrionProductivityPackOutlookAddin.dll adxWSbcls         12016   +3 TadxTheme.DoThemeChanged
23161fa5 +00005 OrionProductivityPackOutlookAddin.dll adxWSbcls          6413   +1 TadxContainerPane.DoThemeChanged
23175b58 +0003c OrionProductivityPackOutlookAddin.dll adxWSbcls         14557   +4 TadxThemeChanged.WndProc
22d074b8 +0002c OrionProductivityPackOutlookAddin.dll Vcl.Controls                 TWinControl.MainWndProc
22bce6a8 +00014 OrionProductivityPackOutlookAddin.dll System.Classes               StdWndProc
22b15f43 +0004b OrionProductivityPackOutlookAddin.dll madExcept                    TIMESettings.GetPropBool
7733c6cb +0004b ntdll.dll                                                          KiUserCallbackDispatcher
73d62b3a +0000a win32u.dll                                                         NtUserGetMessage
7466a79a +0002a USER32.dll                                                         GetMessageW
22b3405b +002f7 OrionProductivityPackOutlookAddin.dll madExcept                    HandleException
22b3c8ea +0003a OrionProductivityPackOutlookAddin.dll madExcept                    InterceptAHandleExcept
22d074f3 +00067 OrionProductivityPackOutlookAddin.dll Vcl.Controls                 TWinControl.MainWndProc
7733c711 +00021 ntdll.dll                                                          KiUserExceptionDispatcher
7733c6cb +0004b ntdll.dll                                                          KiUserCallbackDispatcher
7468390d +1912d USER32.dll                                                         CallNextHookEx
2316e99b +003df OrionProductivityPackOutlookAddin.dll adxWSbcls         11950 +103 TadxOLMessageHook.MessageHookProc
23170364 +00014 OrionProductivityPackOutlookAddin.dll adxWSbcls         12424   +2 TadxTheme.SetThemeColorIndex
231703ec +00080 OrionProductivityPackOutlookAddin.dll adxWSbcls         12444  +13 TadxTheme.Refresh
2316ef51 +00005 OrionProductivityPackOutlookAddin.dll adxWSbcls         12014   +1 TadxTheme.DoThemeChanged
23161fa5 +00005 OrionProductivityPackOutlookAddin.dll adxWSbcls          6413   +1 TadxContainerPane.DoThemeChanged
23175b58 +0003c OrionProductivityPackOutlookAddin.dll adxWSbcls         14557   +4 TadxThemeChanged.WndProc
22d074b8 +0002c OrionProductivityPackOutlookAddin.dll Vcl.Controls                 TWinControl.MainWndProc
22bce6a8 +00014 OrionProductivityPackOutlookAddin.dll System.Classes               StdWndProc
7733c6cb +0004b ntdll.dll                                                          KiUserCallbackDispatcher
74668fef +0012f USER32.dll                                                         PeekMessageW
76ec8482 +00022 KERNEL32.DLL                                                       BaseThreadInitThunk

main thread ($1dd0), inner exception level 2:
>> EAccessViolation, Access violation at address 2316F19E in module 'OrionProductivityPackOutlookAddin.dll'. Read of address 000000A4
2316f19e +0da OrionProductivityPackOutlookAddin.dll adxWSbcls      12057  +7 TadxTheme.InitThemeColor
2318461d +005 OrionProductivityPackOutlookAddin.dll adxWSbcls      22702  +1 TadxOLContainerPane2013.InitThemeColor
23185521 +005 OrionProductivityPackOutlookAddin.dll adxWSbcls      23963  +1 TadxOLContainerPane2016.InitThemeColor
23170364 +014 OrionProductivityPackOutlookAddin.dll adxWSbcls      12424  +2 TadxTheme.SetThemeColorIndex
231703ec +080 OrionProductivityPackOutlookAddin.dll adxWSbcls      12444 +13 TadxTheme.Refresh
2316ef51 +005 OrionProductivityPackOutlookAddin.dll adxWSbcls      12014  +1 TadxTheme.DoThemeChanged
23161fa5 +005 OrionProductivityPackOutlookAddin.dll adxWSbcls       6413  +1 TadxContainerPane.DoThemeChanged
23175b58 +03c OrionProductivityPackOutlookAddin.dll adxWSbcls      14557  +4 TadxThemeChanged.WndProc
22d074b8 +02c OrionProductivityPackOutlookAddin.dll Vcl.Controls             TWinControl.MainWndProc
22bce6a8 +014 OrionProductivityPackOutlookAddin.dll System.Classes           StdWndProc
7733c6cb +04b ntdll.dll                                                      KiUserCallbackDispatcher
74668fef +12f USER32.dll                                                     PeekMessageW
76ec8482 +022 KERNEL32.DLL                                                   BaseThreadInitThunk


I will analyze earlier postings to this thread and see if I can get this fixed.
Posted 18 Sep, 2018 13:40:26 Top
GKoehn




Posts: 39
Joined: 2009-03-23
My Co-Workers have been having the issue, but I have not.

Now I can duplicate it by using Tim Smet's "broadcastspam.exe".
My Email Read Inspector has a task pane at the top.

1) I start Outlook.
2) Start "broadcastspam.exe".
3) Check on the checkbox in "broadcastspam.exe".
4) Click on button "ButSysColorchange" and that does PostMessage(HWND_BROADCAST, WM_SYSCOLORCHANGE, 0, 0) in a loop.
5) I open an existing email and I can see my Task Pane.
6) I close the email and then the error shows.
Posted 18 Sep, 2018 20:38:41 Top
Tim Smet




Posts: 37
Joined: 2015-10-06
Hey GKoehn,

if you have an addin express with sources adding "if not Assigned(FThemeColor) then exit" at the beginning of "TadxTheme.InitThemeColor" in the adxWSbcls.pas file should fix this problem.

Depending on when WM_SYSCOLORCHANGE is received the bug can happen because FThemeColor was nil giving you an access violation trying to access properties from it.

We had customers having this problem in our word addin, but we went back to he previous version of our addin build against older addin express as there must be some other bug (at least related to word) that makes word randomly crash on clients computers with our addin build against latest addin express version. So i never tested the fix in the wild but i do think it should solve it.

I was never able to make the random word crashing bug happen on my pc's nor was i able to get this exception from this topic on a normal way (without broadcast spam) but it did happen with clients under normal circumstances, i just never knew how it happend or under which conditions. Must be timing related as well (like when the WM_SYSCOLORCHANGE arrives).

So if you have the sources try adding that line i mentioned and test with your collegues to see if its fixed with them
Posted 19 Sep, 2018 02:25:05 Top
Andrei Smolin


Add-in Express team


Posts: 18421
Joined: 2006-05-11
Hello Tim, GKoehn, and Ronald,

We've found that every TAdxTheme.Initialization call created a new TadxThemeChanged. Also, there was an exception when InitThemeColor accessed a non-existing ThemeColor. We've created a build to address these issues; I'll send you a download link in a couple of minutes.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 19 Sep, 2018 04:03:56 Top