question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Exception StackTrace shows a method not in code!

See original GitHub issue

Hi,

I see an exception and I try to relate the exception stack trace with the code, but as per the code, the top method in stack is not there in code! What am I not able to see here?

[Error] System.AggregateException: One or more errors occurred. (One or more errors occurred. (Access is denied) (Access is denied)) ---> System.AggregateException: One or more errors occurred. (Access is denied) (Access is denied) ---> System.Security.SecurityException: Access is denied
   at System.Security.Principal.WindowsIdentity.GetCurrentInternal(TokenAccessLevels desiredAccess, Boolean threadOnly)
   at Microsoft.Data.ProviderBase.DbConnectionPoolIdentity.GetCurrentNative()
   at Microsoft.Data.ProviderBase.DbConnectionPoolGroup.GetConnectionPool(DbConnectionFactory connectionFactory)
   at Microsoft.Data.ProviderBase.DbConnectionFactory.GetConnectionPool(DbConnection owningObject, DbConnectionPoolGroup connectionPoolGroup)
   at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   at Microsoft.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   at Microsoft.Data.SqlClient.SqlConnection.OpenAsync(CancellationToken cancellationToken)

As per the source code https://github.com/dotnet/SqlClient/blob/master/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionPoolIdentity.Windows.cs, there is no call made to “WindowsIdentity.GetCurrentInternal”. Then why is the stack trace showing it?

I get this exception when I try to impersonate another person on my machine (which succeeds) but SQL Client is unable to open a connection.

Can anyone help?

TIA!

Nayan

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cheenamalhotracommented, Feb 14, 2020

We call Windows.GetCurrent()

https://github.com/dotnet/SqlClient/blob/a9dfe480eff5dd344518eab5198654eff969fb6e/src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/ProviderBase/DbConnectionPoolIdentity.Windows.cs#L23

which calls GetCurrentInternal() by making a Sibling/Tail call, which is not captured by Stack Trace.

Reference source: windowsidentity.cs#L263-L267.

Regarding the exception, you might wanna try giving Security permission to the impersonated user account.

0reactions
cheenamalhotracommented, Mar 4, 2020

Closing this issue as answered, if you need support on more topics from SqlClient, please open a new issue with repro attached.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Exception's stacktrace doesn't show where the ...
Typically when I throw an exception, catch it, and print out the stacktrace, I get to see the call where the exception was...
Read more >
Java Stack Trace: How to Read and Understand to Debug ...
Usually, a stack trace is shown when an Exception is not handled correctly in code. (An exception is what a runtime environment uses...
Read more >
c# - How can we avoid showing the literal path in ...
When our in-house developed application (C#, ASP.NET) is throwing an exception, it displays a stack trace that contains path information like C ...
Read more >
Exception.StackTrace Property (System)
The StackTrace property may not report as many method calls as expected because of code transformations, such as inlining, that occur during optimization....
Read more >
#21942 Exception line number at end of method
Briefly, when an exception is thrown and I get a stack trace, the exception line number is set to the last line of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found