dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.47k stars 4.76k forks source link

Access Exception thrown on exit after opening OleDb connection to access database #76712

Open carlintj opened 2 years ago

carlintj commented 2 years ago

Description

We're having an issue where our .Net 6 WinForms application will not exit after we open a connection to an Access database due to an exception being thrown outside of our code. I've been able to recreate the same fault with the code below. No exception is thrown during running, only when the application is exiting. Even more strangely is that we run into this even if the Access database specified in the connection string doesn't exist. What seems to be happening is that an access violation exception is thrown on exit, the application tries to exit, and then another exception is thrown which is causing an endless loop.

accessexception1

Reproduction Steps

Create a .Net 6 console application and use the following for the main body

        var connStr = "Provider=Microsoft.ACE.OLEDB.16.0;Data Source=c:\tfs\testdb.accdb;Persist Security Info=False";
        using (var testConn = new System.Data.OleDb.OleDbConnection(connStr))
        {
            try
            {
                testConn.Open();
                testConn.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }

Expected behavior

Application exits without error

Actual behavior

Application hangs on exit using 100% of a CPU core.

Regression?

This works without error in .Net Framework 4.8

Known Workarounds

No response

Configuration

.Net 6, Windows 10 Business 21H2. Office version installed is Microsoft 365 MSO (Version 2209 Build 16.0.15629.20152) 64-bit

Other information

We have seen this behavior across multiple different machines and have tried many different versions of the access runtimes without any change in behavior.

dotnet-issue-labeler[bot] commented 2 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ghost commented 2 years ago

Tagging subscribers to this area: @roji, @ajcvickers See info in area-owners.md if you want to be subscribed.

Issue Details
### Description We're having an issue where our .Net 6 WinForms application will not exit after we open a connection to an Access database due to an exception being thrown outside of our code. I've been able to recreate the same fault with the code below. No exception is thrown during running, only when the application is exiting. Even more strangely is that we run into this even if the Access database specified in the connection string doesn't exist. What seems to be happening is that an access violation exception is thrown on exit, the application tries to exit, and then another exception is thrown which is causing an endless loop. ![accessexception1](https://user-images.githubusercontent.com/3381715/194316983-bed93f18-44c6-45e3-a938-49a7be9bf419.png) ### Reproduction Steps Create a .Net 6 console application and use the following for the main body using (var testConn = new System.Data.OleDb.OleDbConnection(connStr)) var connStr = "Provider=Microsoft.ACE.OLEDB.16.0;Data Source=c:\tfs\testdb.accdb;Persist Security Info=False"; { try { testConn.Open(); testConn.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } ### Expected behavior Application exits without error ### Actual behavior Application hangs on exit using 100% of a CPU core. ### Regression? This works without error in .Net Framework 4.8 ### Known Workarounds _No response_ ### Configuration .Net 6, Windows 10 Business 21H2. Office version installed is Microsoft 365 MSO (Version 2209 Build 16.0.15629.20152) 64-bit ### Other information We have seen this behavior across multiple different machines and have tried many different versions of the access runtimes without any change in behavior.
Author: carlintj
Assignees: -
Labels: `untriaged`, `area-System.Data.OleDB`
Milestone: -
ajcvickers commented 2 years ago

Possibly related to https://github.com/dotnet/runtime/issues/76054

roji commented 2 years ago

The fact that this doesn't happen in .NET Framework 4.8 may indeed indicate a bug in .NET Core's System.Data.OleDb... And agreed that this could be the same bug as in #76054.

roji commented 2 years ago

Note that a recent ACE update may make this go away (or it may hide a bug still present in System.Data.OleDb), see https://github.com/dotnet/runtime/issues/76054#issuecomment-1270753718.