Skip to content

Remove CER #3535

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

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1411,18 +1411,6 @@ private void BeginExecuteNonQueryInternalReadStage(TaskCompletionSource<object>
CachedAsyncState.SetActiveConnectionAndResult(completion, nameof(EndExecuteNonQuery), _activeConnection);
_stateObj.ReadSni(completion);
}
// Cause of a possible unstable runtime situation on facing with `OutOfMemoryException` and `StackOverflowException` exceptions,
// trying to call further functions in the catch of either may fail that should be considered on debuging!
catch (System.OutOfMemoryException e)
{
_activeConnection.Abort(e);
throw;
}
catch (System.StackOverflowException e)
{
_activeConnection.Abort(e);
throw;
}
catch (Exception)
{
// Similarly, if an exception occurs put the stateObj back into the pool.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this catch be calling _activeConnection.Abort(e) like the other catches used to?

Same with the other 2 below.

Expand Down Expand Up @@ -1968,20 +1956,6 @@ private void BeginExecuteXmlReaderInternalReadStage(TaskCompletionSource<object>
CachedAsyncState.SetActiveConnectionAndResult(completion, nameof(EndExecuteXmlReader), _activeConnection);
_stateObj.ReadSni(completion);
}
// Cause of a possible unstable runtime situation on facing with `OutOfMemoryException` and `StackOverflowException` exceptions,
// trying to call further functions in the catch of either may fail that should be considered on debuging!
catch (System.OutOfMemoryException e)
{
_activeConnection.Abort(e);
completion.TrySetException(e);
throw;
}
catch (System.StackOverflowException e)
{
_activeConnection.Abort(e);
completion.TrySetException(e);
throw;
}
catch (Exception e)
{
// Similarly, if an exception occurs put the stateObj back into the pool.
Expand Down Expand Up @@ -2633,20 +2607,6 @@ private void BeginExecuteReaderInternalReadStage(TaskCompletionSource<object> co
CachedAsyncState.SetActiveConnectionAndResult(completion, nameof(EndExecuteReader), _activeConnection);
_stateObj.ReadSni(completion);
}
// Cause of a possible unstable runtime situation on facing with `OutOfMemoryException` and `StackOverflowException` exceptions,
// trying to call further functions in the catch of either may fail that should be considered on debuging!
catch (System.OutOfMemoryException e)
{
_activeConnection.Abort(e);
completion.TrySetException(e);
throw;
}
catch (System.StackOverflowException e)
{
_activeConnection.Abort(e);
completion.TrySetException(e);
throw;
}
catch (Exception e)
{
// Similarly, if an exception occurs put the stateObj back into the pool.
Expand Down Expand Up @@ -4114,9 +4074,7 @@ private SqlDataReader GetParameterEncryptionDataReader(out Task returnTask, Task
SqlCommand command = (SqlCommand)state;
bool processFinallyBlockAsync = true;
bool decrementAsyncCountInFinallyBlockAsync = true;
#if NETFRAMEWORK
RuntimeHelpers.PrepareConstrainedRegions();
#endif

try
{
// Check for any exceptions on network write, before reading.
Expand Down Expand Up @@ -4187,10 +4145,7 @@ private SqlDataReader GetParameterEncryptionDataReaderAsync(out Task returnTask,
{
bool processFinallyBlockAsync = true;
bool decrementAsyncCountInFinallyBlockAsync = true;

#if NETFRAMEWORK
RuntimeHelpers.PrepareConstrainedRegions();
#endif

try
{
// Check for any exceptions on network write, before reading.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1237,35 +1237,12 @@ public override void ChangeDatabase(string database)
SqlStatistics statistics = null;
RepairInnerConnection();
SqlClientEventSource.Log.TryCorrelationTraceEvent("SqlConnection.ChangeDatabase | API | Correlation | Object Id {0}, Activity Id {1}, Database {2}", ObjectID, ActivityCorrelator.Current, database);
TdsParser bestEffortCleanupTarget = null;

#if NETFRAMEWORK
RuntimeHelpers.PrepareConstrainedRegions();
#endif

try
{
bestEffortCleanupTarget = SqlInternalConnection.GetBestEffortCleanupTarget(this);
statistics = SqlStatistics.StartTimer(Statistics);
InnerConnection.ChangeDatabase(database);
}
catch (System.OutOfMemoryException e)
{
Abort(e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we still be calling Abort(e)?

throw;
}
catch (System.StackOverflowException e)
{
Abort(e);
throw;
}
catch (System.Threading.ThreadAbortException e)
{
Abort(e);
#if NETFRAMEWORK
SqlInternalConnection.BestEffortCleanup(bestEffortCleanupTarget);
#endif
throw;
}
finally
{
SqlStatistics.StopTimer(statistics);
Expand Down Expand Up @@ -1328,15 +1305,10 @@ public override void Close()
}

SqlStatistics statistics = null;
TdsParser bestEffortCleanupTarget = null;
Exception e = null;

#if NETFRAMEWORK
RuntimeHelpers.PrepareConstrainedRegions();
#endif

try
{
bestEffortCleanupTarget = SqlInternalConnection.GetBestEffortCleanupTarget(this);
statistics = SqlStatistics.StartTimer(Statistics);

Task reconnectTask = _currentReconnectionTask;
Expand All @@ -1362,27 +1334,6 @@ public override void Close()
_statistics._closeTimestamp = ADP.TimerCurrent();
}
}
catch (System.OutOfMemoryException ex)
{
e = ex;
Abort(ex);
throw;
}
catch (System.StackOverflowException ex)
{
e = ex;
Abort(ex);
throw;
}
catch (System.Threading.ThreadAbortException ex)
{
e = ex;
Abort(ex);
#if NETFRAMEWORK
SqlInternalConnection.BestEffortCleanup(bestEffortCleanupTarget);
#endif
throw;
}
catch (Exception ex)
{
e = ex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,6 @@ internal SqlInternalConnectionTds(
_parserLock.Wait(canReleaseFromAnyThread: false);
ThreadHasParserLockForClose = true; // In case of error, let ourselves know that we already own the parser lock

#if NETFRAMEWORK
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did these netcore files have #if NETFRAMEWORK in them anyway? Was it an effort to make them similar to the netfx files so the merge would be simpler?

RuntimeHelpers.PrepareConstrainedRegions();
#endif
try
{
_timeout = TimeoutTimer.StartSecondsTimeout(connectionOptions.ConnectTimeout);
Expand Down Expand Up @@ -573,21 +570,6 @@ internal SqlInternalConnectionTds(
}
}
}
catch (System.OutOfMemoryException)
{
DoomThisConnection();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No more doom on an exception?

throw;
}
catch (System.StackOverflowException)
{
DoomThisConnection();
throw;
}
catch (System.Threading.ThreadAbortException)
{
DoomThisConnection();
throw;
}
finally
{
ThreadHasParserLockForClose = false;
Expand Down Expand Up @@ -2136,39 +2118,18 @@ internal bool GetSessionAndReconnectIfNeeded(SqlConnection parent, int timeout =

try
{
#if NETFRAMEWORK
RuntimeHelpers.PrepareConstrainedRegions();
#endif
try
Task reconnectTask = parent.ValidateAndReconnect(() =>
{
Task reconnectTask = parent.ValidateAndReconnect(() =>
{
ThreadHasParserLockForClose = false;
_parserLock.Release();
releaseConnectionLock = false;
}, timeout);
if (reconnectTask != null)
{
AsyncHelper.WaitForCompletion(reconnectTask, timeout);
return true;
}
return false;
}
catch (System.OutOfMemoryException)
{
DoomThisConnection();
throw;
}
catch (System.StackOverflowException)
{
DoomThisConnection();
throw;
}
catch (System.Threading.ThreadAbortException)
ThreadHasParserLockForClose = false;
_parserLock.Release();
releaseConnectionLock = false;
}, timeout);
if (reconnectTask != null)
{
DoomThisConnection();
throw;
AsyncHelper.WaitForCompletion(reconnectTask, timeout);
return true;
}
return false;
}
finally
{
Expand Down Expand Up @@ -2475,10 +2436,6 @@ internal bool TryGetFedAuthTokenLocked(SqlFedAuthInfo fedAuthInfo, DbConnectionP
// Variable which indicates if we did indeed manage to acquire the lock on the authentication context, to try update it.
bool authenticationContextLocked = false;

// Prepare CER to ensure the lock on authentication context is released.
#if NETFRAMEWORK
RuntimeHelpers.PrepareConstrainedRegions();
#endif
try
{
// Try to obtain a lock on the context. If acquired, this thread got the opportunity to update.
Expand Down
Loading
Loading