Skip to content

Microsoft.Data.SqlClient.SNI.x64.dll crashes when using multiple AppDomains in IIS Express and IIS Server #1418

Closed

Description

@MojoDK

Describe the bug

In my .NetFramework 4.8 web app, I "Start Wihout Debugging" and everything works fine, bu when I rebuild the project, I get the errror below. I have to "Start Without Debugging" again, to make the website work again (and then it crashes againg when rebuilding etc).

From event viewer (sorry it is in Danish):

Program.
Application Error
Event ID 1000

Navn på program med fejl: iisexpress.exe, version: 10.0.22377.1000, tidsstempel: 0x8db0c0a2
Navn på modul med fejl: Microsoft.Data.SqlClient.SNI.x64.dll, version: 4.0.0.0, tidsstempel: 0x61953095
Undtagelseskode: 0xc0000409
Forskydning med fejl 0x000000000001c80c
Proces-id 0xff14
Programmets starttidspunkt 0x01d7e767da588b02
Programsti: C:\Program Files\IIS Express\iisexpress.exe
Modulsti: C:\Users\mora\AppData\Local\Temp\Temporary ASP.NET Files\vs\1453ae1f\938c099f\assembly\dl3\7084a998\0061005c_e1dcd701\Microsoft.Data.SqlClient.SNI.x64.dll
Rapport-id: a6347776-fe45-45b4-a202-d971b9ac10a9
Fuldt navn på program med fejl:
Relativt program-id for program med fejl:

Exception message:
None 

Stack trace:
None

To reproduce

Include a complete code listing (or project/solution) that we can run to reproduce the issue.

Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.

I can't reproduce with a new project.

Expected behavior

Not crashing iisexpress.exe and let me build and refresh the website.

Further technical details

Microsoft.Data.SqlClient version: 4.0.0.0
.NET target: Framework 4.8
SQL Server version: Sql Server 2019
Operating system: Windows 11 Pro x64

Additional context
Add any other context about the problem here.

Activity

  1. JRahnama commented on Dec 8, 2021

    @JRahnama
    Contributor

    @MojoDK have you tried to manually copy paste the required dll and see if that works?

  2. MojoDK commented on Dec 9, 2021

    @MojoDK
    Author

    @JRahnama the "Microsoft.Data.SqlClient.SNI.x64.dll" is already in the bin folder - if I copy (overwrite) it with another "Microsoft.Data.SqlClient.SNI.x64.dll" file, the error is the same.

  3. JRahnama commented on Dec 9, 2021

    @JRahnama
    Contributor

    @MojoDK are you able to reproduce the issue with a simple newly created application? or can you provide a repro please?

  4. leonmeijer commented on Jan 11, 2022

    @leonmeijer

    We're having the same issue. For us it happens in an application with multiple app domains. When the second app domain loads and begins doing a database function, the application crashes hard with no stack trace in Visual Studio. We have the same error codes in Event Viewer. Downgrading to v3 resolved it for now.

  5. jaymonson commented on Jan 11, 2022

    @jaymonson

    We are having the same issue. It is intermittent but at times can occur frequently. When it occurs we get the following crashstack:

    Faulting application name: w3wp.exe, version: 10.0.17763.1, time stamp: 0xcfdb13d8
    Faulting module name: Microsoft.Data.SqlClient.SNI.x64.dll, version: 4.0.0.0, time stamp: 0x61953095
    Exception code: 0xc0000409
    Fault offset: 0x000000000001c80c
    Faulting process id: 0x228c
    Faulting application start time: 0x01d7f3989332762e
    Faulting application path: c:\windows\system32\inetsrv\w3wp.exe
    Faulting module path: C:\inetpub\wwwroot\C2SWeb\C2SWebAdministrator\bin\Microsoft.Data.SqlClient.SNI.x64.dll
    Report Id: 3b4dba21-3703-43ee-9ad7-fdd3c0b15863
    Faulting package full name:
    Faulting package-relative application ID:

    I have not yet experienced the crash while in Visual Studio with debugger attached. I have seen the
    crash on a Server 2019 with SQL 2019 and also on a Server 2019 with SQL 2017.

  6. JRahnama commented on Jan 11, 2022

    @JRahnama
    Contributor

    @leonmeijer and @jaymonson are you on Windows 11 as well and the issue does not happen when downgrading to Microsoft.Data.SqlClient v3?

  7. jaymonson commented on Jan 11, 2022

    @jaymonson
  8. tdhintz commented on Jan 11, 2022

    @tdhintz

    The @jaymonson issue occurs on a redirect. It didn't happen on the latest System.Data.SqlClient, but it does on Microsoft.Data.SqlClient. It feels like it is losing some sort of thread context.

  9. leonmeijer commented on Jan 11, 2022

    @leonmeijer
  10. tdhintz commented on Jan 11, 2022

    @tdhintz

    For the record, our test environments are typically Encryption true, certificates trusted.

  11. waf commented on Jan 14, 2022

    @waf

    Also seeing this, on Windows 10, .NET Framework with Encrypt=False. It's not just IISExpress; it's also crashing w3wp.exe (as @jaymonson's earlier log showed).

    Happening for all members of our development team. When debugging from Visual Studio the first time after building it crashes; after crashing once it then starts OK on subsequent debug launches until the next build.

    Event Log Entry
    Faulting application name: w3wp.exe, version: 10.0.19041.1, time stamp: 0x58c67bf3
    Faulting module name: Microsoft.Data.SqlClient.SNI.x64.dll, version: 4.0.0.0, time stamp: 0x61953095
    Exception code: 0xc0000409
    Fault offset: 0x000000000001c80c
    Faulting process id: 0x6f7c
    Faulting application start time: 0x01d8091b05a21bbc
    Faulting application path: c:\windows\system32\inetsrv\w3wp.exe
    Faulting module path: C:\Projects\web\lib\Microsoft.Data.SqlClient.SNI.x64.dll
    Report Id: 6e33d06d-be0e-4496-b5dd-f82c5285eb01
    Faulting package full name: 
    Faulting package-relative application ID: 
    
  12. agclark27 commented on Jan 24, 2022

    @agclark27

    We're observing the same crashes of w3wp.exe with the same exception code and fault offset in Microsoft.Data.SqlClient.SNI.x64.dll. We checked all of our Splunk logs, and the issue wasn't present when we were on 3.x, but it immediately began appearing with 4.0.0 and remains present in 4.0.1.

  13. JRahnama commented on Jan 24, 2022

    @JRahnama
    Contributor

    @waf and @agclark27 is it happening with a fresh build application even? Can you make a minimal repro with the issue happening and send it to us?

  14. agclark27 commented on Jan 24, 2022

    @agclark27

    Yes, it'll happen throughout the day, even with fresh builds, and we're resetting the IIS app pool overnight each day. There are no memory pressure issues on the servers at the time the crashes occur. I'll see if we can attach DebugDiag to these to get a stack trace when the process crashes.

  15. JRahnama commented on Jan 24, 2022

    @JRahnama
    Contributor

    Have you tested this issue?
    This blog could be helpful as well.

  16. 45 remaining items

  17. lcheunglci commented on Aug 30, 2022

    @lcheunglci
    Contributor

    Any progress on this? On my local dev system (Windows 10) I am experiencing both the memory leak (There is insufficient system memory in resource pool default to run this query) AND the SNI crash.

    I'm not sure if this will resolve the memory leak that you're encountering, but for the SNI crash fix is currently in review and once it's merged, it will be included in the next 5.0 hotfix release.

    Any news on this? Isn't it same bug as #1687?

    No, #1687 is a different issue and the fix from here won't resolve the unloading issue.

  18. isandburn commented on Sep 13, 2022

    @isandburn

    Not to belabor the issue, but I think that I too have been experiencing this issue... below is the abbreviated stacktrace I am seeing when debugging the static crash data in VS 2022. @lcheunglci - Could you (or someone) please verify that this is in fact the same issue being addressed in the coming 5.0 hotfix? This also may help others identify is this is in fact their issue as well. Any/All help is greatly appreciated. EDIT: adding @DavoudEshtehari

    Microsoft.Data.SqlClient.SNI.x64.dll!SNITraceLogging::registerProvider(void)	
    Microsoft.Data.SqlClient.SNI.x64.dll!SNIInitializeEx�()	
    Microsoft.Data.SqlClient.SNI.x64.dll!SNIInitialize�()	
    00007fff00694ee2()	
    00007fff006946bf()	
    00007fff00694695()	
    00007fff006940fc()	
    clr.dll!CallDescrWorkerInternal�()	
    clr.dll!CallDescrWorkerWithHandler()	
    clr.dll!DispatchCallDebuggerWrapper(struct CallDescrData *,class ContextTransitionFrame *,int)	
    clr.dll!DispatchCallSimple()	
    clr.dll!MethodTable::RunClassInitEx()	
    clr.dll!MethodTable::DoRunClassInitThrowing()	
    clr.dll!MethodTable::CheckRunClassInitThrowing()	
    clr.dll!JIT_GetSharedNonGCStaticBase_Helper()	
    00007fff00693efc()	
    clr.dll!CallDescrWorkerInternal�()	
    clr.dll!CallDescrWorkerWithHandler()	
    clr.dll!DispatchCallDebuggerWrapper(struct CallDescrData *,class ContextTransitionFrame *,int)	
    clr.dll!DispatchCallSimple()	
    clr.dll!MethodTable::RunClassInitEx()	
    clr.dll!MethodTable::DoRunClassInitThrowing()	
    clr.dll!MethodTable::CheckRunClassInitThrowing()	
    clr.dll!JIT_GetSharedNonGCStaticBase_Helper()	
    
    ... skipping a bunch of tokenized-named functions for brevity...
    
    clr.dll!CallDescrWorkerInternal�()	
    clr.dll!CallDescrWorkerWithHandler()	
    clr.dll!MethodDescCallSite::CallTargetWorker()	
    clr.dll!QueueUserWorkItemManagedCallback(void *)	
    clr.dll!ManagedThreadBase_DispatchInner()	
    clr.dll!ManagedThreadBase_DispatchMiddle()	
    clr.dll!ManagedThreadBase_DispatchOuter()	
    clr.dll!ManagedThreadBase_DispatchInCorrectAD()	
    clr.dll!Thread::DoADCallBack(struct ADID,void (*)(void *),void *,int)	
    clr.dll!ManagedThreadBase_DispatchInner()	
    clr.dll!ManagedThreadBase_DispatchMiddle()	
    clr.dll!ManagedThreadBase_DispatchOuter()	
    clr.dll!ManagedThreadBase_FullTransitionWithAD()	
    clr.dll!ManagedPerAppDomainTPCount::DispatchWorkItem()	
    clr.dll!ThreadpoolMgr::ExecuteWorkRequest()	
    clr.dll!ThreadpoolMgr::WorkerThreadStart()	
    clr.dll!Thread::intermediateThreadProc(void *)	
    kernel32.dll!BaseThreadInitThunk�()	
    ntdll.dll!RtlUserThreadStart�()
    
  19. lcheunglci commented on Sep 13, 2022

    @lcheunglci
    Contributor

    Not to belabor the issue, but I think that I too have been experiencing this issue... below is the abbreviated stacktrace I am seeing when debugging the static crash data in VS 2022. @lcheunglci - Could you (or someone) please verify that this is in fact the same issue being addressed in the coming 5.0 hotfix? This also may help others identify is this is in fact their issue as well. Any/All help is greatly appreciated. EDIT: adding @DavoudEshtehari

    Microsoft.Data.SqlClient.SNI.x64.dll!SNITraceLogging::registerProvider(void)	
    Microsoft.Data.SqlClient.SNI.x64.dll!SNIInitializeEx�()	
    Microsoft.Data.SqlClient.SNI.x64.dll!SNIInitialize�()	
    

    Yes, the fix will resolve this issue. As the issue lies in the registerProvider SNI method when registering the same provider more than once.

  20. DavoudEshtehari commented on Sep 15, 2022

    @DavoudEshtehari
    Contributor

    The PR has been merged and will be in the next release.

  21. isandburn commented on Sep 15, 2022

    @isandburn

    @DavoudEshtehari - that's great news, thank you. unfortunately i am not familiar with your release cadence - do you have any estimation on when i may expect next release?

  22. DavoudEshtehari commented on Sep 15, 2022

    @DavoudEshtehari
    Contributor

    Two recent hotfixes 4.0.2 and 4.1.1 ship this fix. And, the next version 5.1 will be released till end of this year.

    Release Notes

  23. gregpakes commented on Sep 21, 2022

    @gregpakes

    @DavoudEshtehari - We are experiencing this issue and we are using 5.0.0.

    When you said 5.1 will be released by the end of the year - did you mean that? I guess I'll have to use 4.1.1

  24. DavoudEshtehari commented on Sep 22, 2022

    @DavoudEshtehari
    Contributor

    @gregpakes Yes, 5.1 is on the plan to be released this year.

  25. tdhintz commented on Sep 29, 2022

    @tdhintz

    A patch for 5.0 is needed asap as well.

  26. JRahnama commented on Sep 29, 2022

    @JRahnama
    Contributor

    @tdhintz we are planning on a hotfix of 5.0.1. Date yet to be decided.

  27. tdhintz commented on Sep 30, 2022

    @tdhintz

    Can you give any background that would be useful in understanding the root cause? I have an Win server 2016 running IIS in an x64 app pool on an 8 core virtual. It isn't under much load, yet it seems to crash. The crash occurs about the same time a group of sessions are ended together.

  28. DavoudEshtehari commented on Oct 11, 2022

    @DavoudEshtehari
    Contributor

    I'm glad to announce that Microsoft.Data.SqlClient v5.0.1 has been released.

  29. xiangdguo commented on Jan 7, 2025

    @xiangdguo

    We are still seeing the same exception in Windows Event Log with MDS 5.2 as below.

    Faulting module name: Microsoft.Data.SqlClient.SNI.x86.dll, version: 5.2.0.0, time stamp: 0x65d526aa
    Exception code: 0xc0000409
    Fault offset: 0x000013fb

    Microsoft.Data.SqlClient version: 5.2.2
    .NET target: .NET Framework 4.7.2,
    SQL Server version: SQL Server 2017
    Operating system: Windows Server 2019

  30. xiangdguo commented on Jan 14, 2025

    @xiangdguo

    Hi @DavoudEshtehari

    I'm glad to announce that Microsoft.Data.SqlClient v5.0.1 has been released.

    In your release note it was said "Updated Microsoft.Data.SqlClient.SNI (.NET Framework dependency) and Microsoft.Data.SqlClient.SNI.runtime (.NET Core/Standard dependency) version to 5.0.1 #1795, which includes the fix for AppDomain crash introducing in issue #1418."

    Does it mean you have not updated the SNI dlls for .Net framework 4.x yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions