Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug Assertion Failure : incorrect initial ParseSynonyms size #3016

Open
apoorvdeshmukh opened this issue Nov 18, 2024 · 0 comments · May be fixed by #3088
Open

Debug Assertion Failure : incorrect initial ParseSynonyms size #3016

apoorvdeshmukh opened this issue Nov 18, 2024 · 0 comments · May be fixed by #3088
Assignees
Labels
🐛 Bug! Issues that are bugs in the drivers we maintain. ✔️ Triage Done Issues that are triaged by dev team and are in investigation.

Comments

@apoorvdeshmukh
Copy link
Contributor

Describe the bug

A debug assertion is currently being failed in debug mode irrespective of connectionstring used in application code.

Exception message:
Stack trace:
Process terminated. Assertion failed.
incorrect initial ParseSynonyms size
   at Microsoft.Data.SqlClient.SqlConnectionString.GetParseSynonyms() in C:\Users\apdeshmukh\git\sqlclient\src\Microsoft.Data.SqlClient\src\Microsoft\Data\SqlClient\SqlConnectionString.cs:line 861
   at Microsoft.Data.SqlClient.SqlConnectionString..ctor(String connectionString) in C:\Users\apdeshmukh\git\sqlclient\src\Microsoft.Data.SqlClient\src\Microsoft\Data\SqlClient\SqlConnectionString.cs:line 291
   at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous) in C:\Users\apdeshmukh\git\sqlclient\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlConnectionFactory.cs:line 144
   at Microsoft.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions) in C:\Users\apdeshmukh\git\sqlclient\src\Microsoft.Data.SqlClient\src\Microsoft\Data\ProviderBase\DbConnectionFactory.cs:line 458
   at Microsoft.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key) in C:\Users\apdeshmukh\git\sqlclient\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlConnectionHelper.cs:line 72
   at Microsoft.Data.SqlClient.SqlConnection.set_ConnectionString(String value) in C:\Users\apdeshmukh\git\sqlclient\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlConnection.cs:line 651
   at Microsoft.Data.SqlClient.SqlConnection..ctor(String connectionString) in C:\Users\apdeshmukh\git\sqlclient\src\Microsoft.Data.SqlClient\netcore\src\Microsoft\Data\SqlClient\SqlConnection.cs:line 160
   at SqlExample.Program.Main(String[] args) in C:\Users\apdeshmukh\source\repos\TestSqlClient\Program.cs:line 14

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.

using System;
using Microsoft.Data.SqlClient;

namespace SqlExample
{
    class Program
    {
        static void Main(string[] args)
        {
            // Define your connection string
            string connString = @"Server=tcp:localhost;Database=Demo2";

            // Create a SQL connection
            using (SqlConnection conn = new SqlConnection(connString))
            {
                // Define your SQL query
                string query = "SELECT @@version";

                // Create a SQL command
                using (SqlCommand cmd = new SqlCommand(query, conn))
                {
                    try
                    {
                        // Open the connection
                        conn.Open();

                        // Execute the command and use a data reader to process the results
                        using (SqlDataReader reader = cmd.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                // Access data by column index or name
                                Console.WriteLine(reader.GetString(0));
                            }
                        }
                    }
                    catch (SqlException ex)
                    {
                        Console.WriteLine($"SQL Error: {ex.Message}");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine($"Error: {ex.Message}");
                    }
                }
            }
        }
    }
}

Expected behavior

Version string printed correctly.
E.g. Microsoft SQL Server 2022 (RTM) - 16.0.5730.0 (X64)
Sep 10 2024 10:56:05 2022.0160.5730.00
Copyright (C) 2022 Microsoft Corporation
Enterprise Edition (64-bit) on Windows Server 2022 Datacenter 10.0 (Build 20348: ) (Hypervisor)

Further technical details

Microsoft.Data.SqlClient version: current main branch
.NET target: (e.g. Framework 4.7.1, Core 2.2.2) .Net 8.0
SQL Server version: (e.g. SQL Server 2017) Sql Server 2022
Operating system: (e.g. Windows 2019, Ubuntu 18.04, macOS 10.13, Docker container) : Windows

Additional context
This count needs to be corrected

Debug.Assert(synonyms.Count == count, "incorrect initial ParseSynonyms size");

@apoorvdeshmukh apoorvdeshmukh added the 🐛 Bug! Issues that are bugs in the drivers we maintain. label Nov 18, 2024
@apoorvdeshmukh apoorvdeshmukh self-assigned this Nov 18, 2024
@cheenamalhotra cheenamalhotra added 🆕 Triage Needed For new issues, not triaged yet. ✔️ Triage Done Issues that are triaged by dev team and are in investigation. and removed 🆕 Triage Needed For new issues, not triaged yet. labels Nov 18, 2024
@edwardneal edwardneal linked a pull request Dec 20, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug! Issues that are bugs in the drivers we maintain. ✔️ Triage Done Issues that are triaged by dev team and are in investigation.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants