This project is read-only.

Stack Overflow behaviour diagnosed by Microsoft

Sep 10, 2009 at 5:28 AM

Hi, i had a problem with the tool after using it for 9 months.

the only thing that changed is chagning the OU strucutre. i noticed that the tool looks and works on the Ldap main tree level and not the OU.

Our Users OU is called "Company Users" and it used to have all the users under it, what we changed is creating the Departments OUs under the main OU "the original OU's name was not changed"

The OU strucutr became like this

Company OU >Department OU

 3 weeks later we started to have a problem access sharepoint and the application pool kept dying on us. we contacted Microsoft and opened a premier support call and it was diagnosed as shown below.

Could this have happened because of creating new OUs under the main OU?

************************

Hi Hany,

Thanks for your patience. After analyzing the dump file (w3wp__PID__13308__Date__09_08_2009__Time_01_44_50PM__256__Kernel32!TerminateProcess.dmp) we find it is a typical “Stack Overflow” issue which is caused by the third party code (You can refer to the 4<sup>th</sup> item below for more information of this product).

 Below is the detail analysis.

 

Our Findings:

===========================================================================================================================================

1              In the dump file, the unmanaged call stack is:

0:029> kL

ChildEBP RetAddr 

20644aec 7a105ba8 kernel32!TerminateProcess 

20644b50 7a105d46 mscorwks!EEPolicy::HandleFatalStackOverflow+0xf2

20644b74 79fe29c5 mscorwks!EEPolicy::HandleStackOverflow+0x173

20644b90 7c828772 mscorwks!COMPlusFrameHandler+0x10b

20644bb4 7c828743 ntdll!RtlRaiseStatus+0xe0

20644c5c 7c82857e ntdll!RtlRaiseStatus+0xb1

20644fa8 7a0ac3d8 ntdll!KiUserExceptionDispatcher+0xe

20644fc4 7a00cd8e mscorwks!ReportStackOverflow+0x61

20644fd4 79e85806 mscorwks!Alloc+0x3b

20645014 79f82bdb mscorwks!FastAllocateObject+0x38

20645024 79f82d9b mscorwks!ComObject::CreateComObjectRef+0x27

20645090 79f82d57 mscorwks!COMInterfaceMarshaler::CreateObjectRef+0x2a

206450dc 79f82a40 mscorwks!COMInterfaceMarshaler::FindOrCreateObjectRef+0xac

20645598 79f8352d mscorwks!GetObjectRefFromComIP+0x1ec

206455b8 79f83512 mscorwks!UnmarshalObjectFromInterface+0x19

206455d4 79f83776 mscorwks!InterfaceMarshalerBase::ConvertSpaceNativeToCLR+0x30

206455dc 79f837fa mscorwks!DefaultMarshalOverrides<InterfaceMarshalerBase>::UnmarshalCLRToNativeByrefInOut+0x8

20645810 79ee250a mscorwks!RunML+0x825

2064586c 01eebc0c mscorwks!NDirectSlimStubWorker2+0xfe

206458f8 67170eb3 0x1eebc0c

 

2              Let’s see why “Stack Overflow” occurred here (The code highlighted in Red stands the ones which has the problem, the words in blue is our comments):

 

0:029> !clrstack

OS Thread Id: 0x327c (29)

ESP       EIP    

20644b10 77e42004 [FaultingExceptionFrame: 20644b10]

20645044 77e42004 [GCFrame: 20645044]

206450b4 77e42004 [GCFrame: 206450b4]

20645130 77e42004 [GCFrame: 20645130]

20645910 77e42004 [NDirectMethodFrameSlim: 20645910] System.DirectoryServices.Interop.UnsafeNativeMethods.IntADsOpenObject(System.String, System.String, System.String, Int32, System.Guid ByRef, System.Object ByRef)

20645930 67170eb3 System.DirectoryServices.Interop.UnsafeNativeMethods.ADsOpenObject(System.String, System.String, System.String, Int32, System.Guid ByRef, System.Object ByRef)

2064596c 67166575 System.DirectoryServices.DirectoryEntry.Bind(Boolean)

206459b0 67166405 System.DirectoryServices.DirectoryEntry.Bind()

206459c0 67165938 System.DirectoryServices.DirectoryEntry.get_AdsObject()

206459d0 6716901e System.DirectoryServices.DirectorySearcher.FindAll(Boolean)

206459ec 67168edb System.DirectoryServices.DirectorySearcher.FindOne()

20645a24 277f56af ADSelfService.clsAD.FindOne(ADProperties, System.String)

20645a60 277f554a ADSelfService.clsAD.FindOneByProperty(ADProperties, System.String)

20645a90 277f59c8 ADSelfService.clsAD.MapToObject(System.DirectoryServices.SearchResult, ADSelfService.clsUser ByRef)

20645ac0 277f555c ADSelfService.clsAD.FindOneByProperty(ADProperties, System.String)

20645af0 277f59c8 ADSelfService.clsAD.MapToObject(System.DirectoryServices.SearchResult, ADSelfService.clsUser ByRef)

20645b20 277f555c ADSelfService.clsAD.FindOneByProperty(ADProperties, System.String)

……

……//The functions FindOneByProperty and MapToObject repeated thousands times here

……

2066eef0 277f59c8 ADSelfService.clsAD.MapToObject(System.DirectoryServices.SearchResult, ADSelfService.clsUser ByRef)

2066ef20 277f555c ADSelfService.clsAD.FindOneByProperty(ADProperties, System.String)

2066ef50 277f59c8 ADSelfService.clsAD.MapToObject(System.DirectoryServices.SearchResult, ADSelfService.clsUser ByRef)

2066ef80 277f555c ADSelfService.clsAD.FindOneByProperty(ADProperties, System.String)

2066efb0 277f59c8 ADSelfService.clsAD.MapToObject(System.DirectoryServices.SearchResult, ADSelfService.clsUser ByRef)

2066efe0 277f555c ADSelfService.clsAD.FindOneByProperty(ADProperties, System.String)

2066f010 277f59c8 ADSelfService.clsAD.MapToObject(System.DirectoryServices.SearchResult, ADSelfService.clsUser ByRef)

2066f040 277f555c ADSelfService.clsAD.FindOneByProperty(ADProperties, System.String)

2066f070 277f4c6e ADSelfService.ADSelfService.CreateChildControls()

2066f0e8 6613e0e8 System.Web.UI.Control.EnsureChildControls()

2066f114 6613cc83 System.Web.UI.Control.PreRenderRecursiveInternal()

2066f128 662607cf System.Web.UI.WebControls.WebParts.WebPart.PreRenderRecursiveInternal()

2066f13c 6613ccfb System.Web.UI.Control.PreRenderRecursiveInternal()

2066f150 6613ccfb System.Web.UI.Control.PreRenderRecursiveInternal()

2066f164 6613ccfb System.Web.UI.Control.PreRenderRecursiveInternal()

2066f178 6613ccfb System.Web.UI.Control.PreRenderRecursiveInternal()

2066f18c 6613ccfb System.Web.UI.Control.PreRenderRecursiveInternal()

2066f1a0 6614e38a System.Web.UI.Page.ProcessRequestMain(Boolean, Boolean)

2066f39c 6614d8c3 System.Web.UI.Page.ProcessRequest(Boolean, Boolean)

2066f3d4 6614d80f System.Web.UI.Page.ProcessRequest()

2066f40c 6614d72f System.Web.UI.Page.ProcessRequestWithNoAssert(System.Web.HttpContext)

2066f414 6614d6c2 System.Web.UI.Page.ProcessRequest(System.Web.HttpContext)

2066f428 65fe6bfb System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()

2066f45c 65fe3f51 System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)

2066f49c 65fe7733 System.Web.HttpApplication+ApplicationStepManager.ResumeSteps(System.Exception)

2066f4ec 65fccbfe System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(System.Web.HttpContext, System.AsyncCallback, System.Object)

2066f508 65fd19c5 System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest)

2066f53c 65fd16b2 System.Web.HttpRuntime.ProcessRequestNoDemand(System.Web.HttpWorkerRequest)

2066f548 65fcfa6d System.Web.Hosting.ISAPIRuntime.ProcessRequest(IntPtr, Int32)

2066f758 79f047fd [ContextTransitionFrame: 2066f758]

2066f78c 79f047fd [GCFrame: 2066f78c]

2066f8e8 79f047fd [ComMethodFrame: 2066f8e8]

 

Based on the managed call stack, we can see the two functions FindOneByProperty and MapToObject had repeated thousands times and that’s why we have the “Stack Overflow” problem here.

 

3               Let’s check why the above two functions repeated so many times (The code highlighted in Red stands the ones which has the problem, the words in blue is our comments):

 

The code path is ADSelfService.ADSelfService.CreateChildControls -> ADSelfService.clsAD.FindOneByProperty -> ADSelfService.clsAD.MapToObject

 

The related source code is:

 

protected override void CreateChildControls();

 

Declaring Type: ADSelfService.ADSelfService

Assembly: ADSelfService, Version=1.0.0.0

 

protected override void CreateChildControls()

{

    base.CreateChildControls();

    try

    {

        clsUser user = new clsUser();

        clsAD sad = new clsAD(this.LDAPPath, this.Username, this.Password);

        this.accountName = WindowsIdentity.GetCurrent().get_Name();

        this.accountName = this.FilterOutDomain(this.accountName);

        user = sad.FindOneByProperty(clsAD.ADProperties.samAccountName, this.accountName);

        if (user.manager != null)

        {

            this.manager = user.manager.displayName + " (Click To Change)";

            this.managerDn = user.manager.distinguishedName;

        }

......

 

public clsUser FindOneByProperty(ADProperties property, string propertyValue);

 

Declaring Type: ADSelfService.clsAD

Assembly: ADSelfService, Version=1.0.0.0

 

public clsUser FindOneByProperty(ADProperties property, string propertyValue)

{

    clsUser objUser = new clsUser();

    try

    {

        SearchResult result = this.FindOne(property, propertyValue);

        if (result != null)

        {

            this.MapToObject(result, ref objUser);    //This is where MapToObject being called

        }

    }

    catch (Exception exception)

    {

        throw new Exception(exception.get_Message().ToString());

    }

    return objUser;

}

 

 

private void MapToObject(SearchResult result, ref clsUser objUser);

 

Declaring Type: ADSelfService.clsAD

Assembly: ADSelfService, Version=1.0.0.0

 

private void MapToObject(SearchResult result, ref clsUser objUser)

{

    try

    {

        if (result.get_Properties().get_Item("title").get_Count() > 0)

        {

            objUser.Title = result.get_Properties().get_Item("title").get_Item(0).ToString();

        }

        if (result.get_Properties().get_Item("distinguishedName").get_Count() > 0)

        {

            objUser.distinguishedName = result.get_Properties().get_Item("distinguishedName").get_Item(0).ToString();

        }

        if (result.get_Properties().get_Item("displayName").get_Count() > 0)

        {

            objUser.displayName = result.get_Properties().get_Item("displayname").get_Item(0).ToString();

        }

        if (result.get_Properties().get_Item("telephoneNumber").get_Count() > 0)

        {

            objUser.telephoneNumber = result.get_Properties().get_Item("telephoneNumber").get_Item(0).ToString();

        }

        if (result.get_Properties().get_Item("samAccountName").get_Count() > 0)

        {

            objUser.samAccountName = result.get_Properties().get_Item("samAccountName").get_Item(0).ToString();

        }

        if (result.get_Properties().get_Item("manager").get_Count() > 0)

        {

            objUser.manager = this.FindOneByProperty(ADProperties.distinguishedName, result.get_Properties().get_Item("manager").get_Item(0).ToString());

           

            //We not sure why FindOneByProperty is called again here and it seems likely shoud be:

                                          objUser.manager = result.get_Properties().get_Item("manager").get_Item(0).ToString());

 

        }

        if (result.get_Properties().get_Item("department").get_Count() > 0)

        {

            objUser.department = result.get_Properties().get_Item("department").get_Item(0).ToString();

        }

    }

    catch (Exception exception)

    {

        throw new Exception(exception.get_Message().ToString());

    }

}

 

4              In the dump we also found the following information, which tell us this module is a third party product provided by OCHUX 2008 :

0:000> lmv m ADSelfService

start    end        module name

24130000 2413c000   ADSelfService   (no symbols)          

    Loaded symbol image file: ADSelfService.dll

    Image path: C:\WINDOWS\assembly\GAC_MSIL\ADSelfService\1.0.0.0__9f4da00116c38ec5\ADSelfService.dll

    Image name: ADSelfService.dll

    Has CLR image header, track-debug-data flag not set

    Timestamp:        Thu Sep 18 15:47:39 2008 (48D2781B)

    CheckSum:         00014817

    ImageSize:        0000C000

    File version:     1.0.0.0

    Product version:  1.0.0.0

    File flags:       0 (Mask 3F)

    File OS:          4 Unknown Win32

    File type:        2.0 Dll

    File date:        00000000.00000000

    Translations:     0000.04b0

    CompanyName:      OCHUX

    ProductName:      ADSelfService

    InternalName:     ADSelfService.dll

    OriginalFilename: ADSelfService.dll

    ProductVersion:   1.0.0.0

    FileVersion:      1.0.0.0

    FileDescription:  ADSelfService

LegalCopyright:   Copyright © OCHUX 2008

 

Our Suggestions:

===========================================================================================================================================

Please provide the above analysis to the vendor of the this customized codes and see if the code logic is expected, and whether they have any ways to optimize the code.

 

 

Sep 10, 2009 at 2:35 PM

Hany

First off, please accept my most sincere regrets that this has caused you so much trouble.

I have seen this once before, and it was because someone had a manager who was set as their manager and vice versa.  Does that make sense?  In other words, someone would be your manager in ad, and you would be set as theirs.  This causes an infinite loop as the web part tries to traverse the structure of AD.  I believe the most recent release of the code has a picket fence in for an occasion just such as this.