SharePoint / sp-dev-docs

SharePoint & Viva Connections Developer Documentation
https://docs.microsoft.com/en-us/sharepoint/dev/
Creative Commons Attribution 4.0 International
1.25k stars 1.01k forks source link

Stack overflow in AddQueryIdAndResultObject (ClientRequest.cs, line 548) #8633

Open Dr-Oli opened 1 year ago

Dr-Oli commented 1 year ago

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

SharePoint CSOM

Developer environment

Windows

What browser(s) / client(s) have you tested

Additional environment details

Desktop application based on .NET 4.7.2 on Windows 10

Describe the bug / error

From time to time when running file.ListItemAllFields my application is crashing. In dump analyses I am finding:

***** Path validation summary ** Response Time (ms) Location Deferred srv Symbol search path is: srv Executable search path is: Windows 10 Version 19044 MP (8 procs) Free x64 Product: WinNt, suite: SingleUserTS Edition build lab: 19041.1.amd64fre.vb_release.191206-1406 Machine Name: Debug session time: Mon Dec 5 10:58:45.000 2022 (UTC + 1:00) System Uptime: 3 days 12:28:43.246 Process Uptime: 0 days 0:31:44.000 ................................................................ ................................................................ ................................................................ ....................................................... Loading unloaded module list ........ This dump file has an exception of interest stored in it. The stored exception information can be accessed via .ecxr. (6904.4ea4): Stack overflow - code c00000fd (first/second chance not available)

+------------------------------------------------------------------------+ This target supports Hardware-enforced Stack Protection. A HW based "Shadow Stack" may be available to assist in debugging and analysis. See aka.ms/userhsp for more info.
dps @ssp

+------------------------------------------------------------------------+

For analysis of this file, run !analyze -v clr!SlowAllocateString+0x3a: 00007ff8a45ff2fe e89de50600 call clr!GetThread (00007ff8a466d8a0) 0:023> !analyze -v


MethodDesc: 00007ff8470f71c0 Method Name: Microsoft.SharePoint.Client.ClientRequest.AddQueryIdAndResultObject(Int64, System.Object) Class: 00007ff8470ef838 MethodTable: 00007ff8470f7358 mdToken: 00000000060000db Module: 00007ff845314428 IsJitted: yes CodeAddr: 00007ff846c0e060 Transparency: Transparent MethodDesc: 00007ff845315f10 Method Name: Microsoft.SharePoint.Client.ClientObject.get_Query() Class: 00007ff84534cdf0 MethodTable: 00007ff845315fd8 mdToken: 000000000600002c Module: 00007ff845314428 IsJitted: yes CodeAddr: 00007ff846c0eee0 Transparency: Transparent MethodDesc: 00007ff847124b18 Method Name: Microsoft.SharePoint.Client.ListItem.LoadExpandoFields() Class: 00007ff84710b268 MethodTable: 00007ff847124cc8 mdToken: 0000000006000602 Module: 00007ff845311e08 IsJitted: yes CodeAddr: 00007ff848f26780 Transparency: Transparent MethodDesc: 00007ff845315f10 Method Name: Microsoft.SharePoint.Client.ClientObject.get_Query() Class: 00007ff84534cdf0 MethodTable: 00007ff845315fd8 mdToken: 000000000600002c Module: 00007ff845314428 IsJitted: yes CodeAddr: 00007ff846c0eee0 Transparency: Transparent MethodDesc: 00007ff847124b18 Method Name: Microsoft.SharePoint.Client.ListItem.LoadExpandoFields() Class: 00007ff84710b268 MethodTable: 00007ff847124cc8 mdToken: 0000000006000602 Module: 00007ff845311e08 IsJitted: yes CodeAddr: 00007ff848f26780 Transparency: Transparent MethodDesc: 00007ff845315f10 Method Name: Microsoft.SharePoint.Client.ClientObject.get_Query() Class: 00007ff84534cdf0 MethodTable: 00007ff845315fd8 mdToken: 000000000600002c Module: 00007ff845314428 IsJitted: yes CodeAddr: 00007ff846c0eee0 Transparency: Transparent MethodDesc: 00007ff847124b18 Method Name: Microsoft.SharePoint.Client.ListItem.LoadExpandoFields() Class: 00007ff84710b268 MethodTable: 00007ff847124cc8 mdToken: 0000000006000602 Module: 00007ff845311e08 IsJitted: yes CodeAddr: 00007ff848f26780 Transparency: Transparent MethodDesc: 00007ff845315f10 Method Name: Microsoft.SharePoint.Client.ClientObject.get_Query() Class: 00007ff84534cdf0 MethodTable: 00007ff845315fd8 mdToken: 000000000600002c Module: 00007ff845314428 IsJitted: yes CodeAddr: 00007ff846c0eee0 Transparency: Transparent MethodDesc: 00007ff847124b18 Method Name: Microsoft.SharePoint.Client.ListItem.LoadExpandoFields() Class: 00007ff84710b268 MethodTable: 00007ff847124cc8 mdToken: 0000000006000602 Module: 00007ff845311e08 IsJitted: yes CodeAddr: 00007ff848f26780 Transparency: Transparent MethodDesc: 00007ff845315f10 Method Name: Microsoft.SharePoint.Client.ClientObject.get_Query() Class: 00007ff84534cdf0 MethodTable: 00007ff845315fd8 mdToken: 000000000600002c Module: 00007ff845314428 IsJitted: yes CodeAddr: 00007ff846c0eee0 Transparency: Transparent MethodDesc: 00007ff847124b18 Method Name: Microsoft.SharePoint.Client.ListItem.LoadExpandoFields() Class: 00007ff84710b268 MethodTable: 00007ff847124cc8 mdToken: 0000000006000602 Module: 00007ff845311e08 IsJitted: yes CodeAddr: 00007ff848f26780 Transparency: Transparent MethodDesc: 00007ff845315f10 Method Name: Microsoft.SharePoint.Client.ClientObject.get_Query() Class: 00007ff84534cdf0 MethodTable: 00007ff845315fd8 mdToken: 000000000600002c Module: 00007ff845314428 IsJitted: yes CodeAddr: 00007ff846c0eee0 Transparency: Transparent

KEY_VALUES_STRING: 1

Key  : Analysis.CPU.mSec
Value: 125031

Key  : Analysis.DebugAnalysisManager
Value: Create

Key  : Analysis.Elapsed.mSec
Value: 144326

Key  : Analysis.IO.Other.Mb
Value: 1

Key  : Analysis.IO.Read.Mb
Value: 1

Key  : Analysis.IO.Write.Mb
Value: 91

Key  : Analysis.Init.CPU.mSec
Value: 1812

Key  : Analysis.Init.Elapsed.mSec
Value: 32658

Key  : Analysis.Memory.CommitPeak.Mb
Value: 901

Key  : CLR.BuiltBy
Value: NET481REL1LAST_C

Key  : CLR.Engine
Value: CLR

Key  : CLR.Version
Value: 4.8.9105.0

Key  : Timeline.OS.Boot.DeltaSec
Value: 304123

Key  : Timeline.Process.Start.DeltaSec
Value: 1904

Key  : WER.OS.Branch
Value: vb_release

Key  : WER.OS.Timestamp
Value: 2019-12-06T14:06:00Z

Key  : WER.OS.Version
Value: 10.0.19041.1

Key  : WER.Process.Version
Value: 2022.4.10.0

....

ERROR_CODE: (NTSTATUS) 0xc00000fd - A new guard page for the stack cannot be created.

Steps to reproduce

This is tricky part as this is happening randomly. Usually (90%) it works but then same files are processed again and it is crashing. Dump file can be shared (it is around 1,5Gb).

Expected behavior

ListItemAllFields should list all fields of checked file without going into endless loop ending with stack overflow error.

ghost commented 1 year ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

Dr-Oli commented 1 year ago

Problem resolved. ClientContext is not thread-safe and we forgot on 2 places to properly create context. If you are creating conext from existing one use ClientContext.Clone (URI).