Fastmm mentions that addin express code is reusing free'd objects

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

Fastmm mentions that addin express code is reusing free'd objects
possible bug & easy fix ? 
Tim Smet




Posts: 12
Joined: 2015-10-06
Hi,

I'm using the latest add in express for vcl version from october the beta version, i was experimenting a bit with my outlook addin in outlook 2016 and used fastmm as a memory manager with full debugging support enabled. While using my addin i got a warning from fastmm about the addin reusing an object that was freed (and thus overwriting memory that does not belong to the object which could lead to all kind of problems).

The offending line is actually not in my code but in the code of adxaddin.pas so from add in express

if not (FHostMajorVersion in [9, 12, 14, 15]) then
      begin
        if Assigned(FSink) then begin
          TadxCommandBarsEventSink(FSink).Disconnect();
          FSink := nil;
        end;
        FSink := TadxCommandBarsEventSink.Create(FAddInModule, TExplorer(ASender).CommandBars);
      end;


more specifically the creation of the commandbarseventsink ...

Now since i noticed the host major version could only be outlook 2003 and outlook 2016 is not that new i'm guessing the set is missing major version 16 from outlook 2016 so like FHostMajorVersion in [9, 12, 14, 15, 16] seems to fix it with me but i'm not certain if it's needed for office 2016, i'm guessing it is since it was needed for 2013, 2010, 2007 etc

Here's the log from fastmm4 it's rather long so sorry


--------------------------------2016/5/13 12:22:46--------------------------------
FastMM has detected an error during a GetMem operation. FastMM detected that a block has been modified after being freed. 

Modified byte offsets (and lengths): 16(4)

The previous block size was: 32

This block was previously allocated by thread 0x22F4, and the stack trace (return addresses) at the time was:
162E69F2 [Vcl.ComCtrls.pas][System][@GetMem$qqri][33986]
162E881B [Vcl.ComCtrls.pas][System][TObject.NewInstance$qqrv][33986]
162EEA59 [Vcl.ComCtrls.pas][System][TInterfacedObject.NewInstance$qqrv][33986]
162E8F76 [Vcl.ComCtrls.pas][System][@ClassCreate$qqrpvzc][33986]
16B1592E [adxAddIn.pas][adxAddIn][TadxCommandBarsEventSink.$bctr$qqrp27Adxaddin.TadxCOMAddInModule51System.%DelphiInterface$t23Office2000._CommandBars%][5979]
162EE9B7 [Vcl.ComCtrls.pas][System][@IntfClear$qqrr45System.%DelphiInterface$t17System.IInterface%][33986]
16B166DA [adxAddIn.pas][adxAddIn][TExplorer.Get_CommandBars$qqrv][6673]
16B356D3 [adxAddIn.pas][adxAddIn][TadxAddin.DoExplorerActivate$qqrp14System.TObject][14642]
162ED1A2 [Vcl.ComCtrls.pas][System][@DynArraySetLength$qqrv][33986]
163A2CB4 [System.Classes][Classes.TCollection.GetItem$qqri]
162E8C17 [Vcl.ComCtrls.pas][System][@IsClass$qqrxp14System.TObjectp17System.TMetaClass][33986]
16B35566 [adxAddIn.pas][adxAddIn][TadxAddin.DoNewExplorer$qqrp14System.TObjectx49System.%DelphiInterface$t21Outlook2000._Explorer%][14604]
16B33EF3 [adxAddIn.pas][adxAddIn][TadxAddin.OnStartupComplete$qqsrp12tagSAFEARRAY][14166]
5CE86F43 [MsoVBADigSigRemoveSignedDataMsg]
5CE63100 [Unknown function at _MsoDrawTextW@20]
1106ED3 [Unknown function at FOutlookIsDeepSyncing@0]
1068DC7 [OlkGetCodepageUI@0]
1068CC6 [OlkGetCodepageUI@0]
1068CC6 [OlkGetCodepageUI@0]
1068BE7 [OlkGetCodepageUI@0]
104410A 

The block was previously used for an object of class: TadxCommandBarsEventSink

The allocation number was: 41163

The block was previously freed by thread 0x22F4, and the stack trace (return addresses) at the time was:
162E6A0E [Vcl.ComCtrls.pas][System][@FreeMem$qqrpv][33986]
162E8839 [Vcl.ComCtrls.pas][System][TObject.FreeInstance$qqrv][33986]
162E8FC1 [Vcl.ComCtrls.pas][System][@ClassDestroy$qqrxp14System.TObject][33986]
16B15A10 [adxAddIn.pas][adxAddIn][TadxCommandBarsEventSink.$bdtr$qqrv][5991]
162EEAC5 [Vcl.ComCtrls.pas][System][TInterfacedObject._Release$qqsv][33986]
5ED32F5C 
5ED32F88 
1641D195 [System.Win.ComObj][Win.Comobj.InterfaceDisconnect$qqrx45System.%DelphiInterface$t17System.IInterface%rx5_GUIDri]
16B15A43 [adxAddIn.pas][adxAddIn][TadxCommandBarsEventSink.Disconnect$qqrv][5996]
16B356AA [adxAddIn.pas][adxAddIn][TadxAddin.DoExplorerActivate$qqrp14System.TObject][14639]
18A99336 [GetRawStackTrace]
16B163C1 [adxAddIn.pas][adxAddIn][TExplorer.InvokeEvent$qqrir42System.%DynamicArray$t17System.OleVariant%][6637]
168B5357 [Vcl.OleServer][Oleserver.TServerEventDispatch.Invoke$7334$ActRec.$0$Body$qqrir42System.%DynamicArray$t17System.OleVariant%]
1641DD1C [System.Win.ComObj][Win.Comobj.EventDispatchInvoke$qqrir13tagDISPPARAMS67System.%DelphiInterface$t39System.Win.Comobj.TEventDispatchInvoker%]
168B53AC [Vcl.OleServer][Oleserver.TServerEventDispatch.Invoke$qqsirx5_GUIDiuspvt5t5t5]
110EF02 [GetMsoInst@4]
110EECD [GetMsoInst@4]
110ECAB [GetMsoInst@4]
110EDCD [GetMsoInst@4]
110EB63 [GetMsoInst@4]
110E6C1 [GetMsoInst@4]

The current thread ID is 0x22F4, and the stack trace (return addresses) leading to this error is:
162F8435 [FastMM4][DebugGetMem$qqri]
162E69F2 [Vcl.ComCtrls.pas][System][@GetMem$qqri][33986]
162E881B [Vcl.ComCtrls.pas][System][TObject.NewInstance$qqrv][33986]
162EEA59 [Vcl.ComCtrls.pas][System][TInterfacedObject.NewInstance$qqrv][33986]
162E8F76 [Vcl.ComCtrls.pas][System][@ClassCreate$qqrpvzc][33986]
16B1592E [adxAddIn.pas][adxAddIn][TadxCommandBarsEventSink.$bctr$qqrp27Adxaddin.TadxCOMAddInModule51System.%DelphiInterface$t23Office2000._CommandBars%][5979]
162EE9B7 [Vcl.ComCtrls.pas][System][@IntfClear$qqrr45System.%DelphiInterface$t17System.IInterface%][33986]
16B166DA [adxAddIn.pas][adxAddIn][TExplorer.Get_CommandBars$qqrv][6673]
16B356D3 [adxAddIn.pas][adxAddIn][TadxAddin.DoExplorerActivate$qqrp14System.TObject][14642]
18A99336 [GetRawStackTrace]
16B163C1 [adxAddIn.pas][adxAddIn][TExplorer.InvokeEvent$qqrir42System.%DynamicArray$t17System.OleVariant%][6637]
168B5357 [Vcl.OleServer][Oleserver.TServerEventDispatch.Invoke$7334$ActRec.$0$Body$qqrir42System.%DynamicArray$t17System.OleVariant%]
1641DD1C [System.Win.ComObj][Win.Comobj.EventDispatchInvoke$qqrir13tagDISPPARAMS67System.%DelphiInterface$t39System.Win.Comobj.TEventDispatchInvoker%]
168B53AC [Vcl.OleServer][Oleserver.TServerEventDispatch.Invoke$qqsirx5_GUIDiuspvt5t5t5]
110EF02 [GetMsoInst@4]
110EECD [GetMsoInst@4]
110ECAB [GetMsoInst@4]
110EDCD [GetMsoInst@4]
110EB63 [GetMsoInst@4]
110E6C1 [GetMsoInst@4]
F93FCCB [Unknown function at ?LsAssert@PTLS7@@YGXH@Z]

Current memory dump of 256 bytes starting at pointer address 7EDF4860:
94 D2 BD 16 80 80 80 80 80 80 80 80 80 80 80 80 00 00 00 00 80 80 80 80 80 80 80 80 80 80 80 80
66 BD A1 9D 80 80 80 80 00 00 00 00 70 40 DF 7E 00 00 00 00 00 00 00 00 D4 83 2F 16 00 00 00 00
A0 A1 00 00 F2 69 2E 16 1B 88 2E 16 76 8F 2E 16 8A BF 42 16 66 70 40 16 6C C7 42 16 E4 28 43 16
B0 2A 43 16 2E 4F B2 16 8C 41 B3 16 43 6F E8 5C 00 31 E6 5C D3 6E 10 01 C7 8D 06 01 C6 8C 06 01
C6 8C 06 01 E7 8B 06 01 0A 41 04 01 24 8C 06 01 4F 90 E1 75 D7 33 2B 77 F4 22 00 00 F4 22 00 00
0E 6A 2E 16 39 88 2E 16 C1 8F 2E 16 4C A7 3F 16 3F 89 2E 16 F9 ED B2 16 95 40 9A 16 31 40 B3 16
43 6F E8 5C 00 31 E6 5C D3 6E 10 01 C7 8D 06 01 C6 8C 06 01 C6 8C 06 01 E7 8B 06 01 0A 41 04 01
24 8C 06 01 4F 90 E1 75 D7 33 2B 77 06 34 2B 77 0C E4 2A 77 24 00 00 00 34 86 3F 16 1D 78 FE 87
  Ò  ½  .                          .  .  .  .                        
f  ½  ¡            .  .  .  .  p  @    ~  .  .  .  .  .  .  .  .    ƒ  /  .  .  .  .  .
  ¡  .  .  ò  i  .  .  .  ˆ  .  .  v    .  .    ¿  B  .  f  p  @  .  l    B  .    (  C  .
  *  C  .  .  O  ²  .  Œ  A  ³  .  C  o  è    .  1  æ      n  .  .      .  .  Æ  Œ  .  .
Æ  Œ  .  .      .  .  .  A  .  .  $  Œ  .  .  O      u    3  +  w    "  .  .    "  .  .
.  j  .  .  9  ˆ  .  .      .  .  L    ?  .  ?    .  .  ù    ²  .    @    .  1  @  ³  .
C  o  è    .  1  æ      n  .  .      .  .  Æ  Œ  .  .  Æ  Œ  .  .      .  .  .  A  .  .
$  Œ  .  .  O      u    3  +  w  .  4  +  w  .    *  w  $  .  .  .  4    ?  .  .  x  þ  
Posted 13 May, 2016 08:27:49 Top
Andrei Smolin


Add-in Express team


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

Thank you very, very much!

We will fix this in the next release.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 13 May, 2016 09:33:11 Top