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

Possible incorrect usage of WeakReference.Target in method FirebirdSql.Data.FirebirdClient.FbConnectionInternal.TransactionUpdated [DNET619] #580

Closed
firebird-automations opened this issue Jul 1, 2015 · 8 comments

Comments

@firebird-automations
Copy link

Submitted by: Alex Gaysinskiy (gasizdat)

Relate to DNET617
Relate to DNET605

Implementation of FirebirdSql.Data.FirebirdClient.FbConnectionInternal.TransactionUpdated function (FirebirdClient\FbConnectionInternal.cs, line 298) has incorrect condition:

            public void TransactionUpdated\(\)
	\{
		for \(int i = 0; i < this\.preparedCommands\.Count; i\+\+\)
		\{
			if \(\!this\.preparedCommands\[i\]\.IsAlive\) //<<<= This check does nothing\. Between this line and the following can happen garbage collection\.
				continue;

			FbCommand command = this\.preparedCommands\[i\]\.Target as FbCommand; //<<<= may be a null

			if \(command\.Transaction \!= null\) //<<<= potential NRE\. Correct code is: command \!= null && command\.Transaction \!= null
			\{
				command\.CloseReader\(\);
				command\.Transaction = null;
			\}
		\}
	\}
@firebird-automations
Copy link
Author

Modified by: Alex Gaysinskiy (gasizdat)

description: Implementation of FirebirdSql.Data.FirebirdClient.FbConnectionInternal.TransactionUpdated function (FirebirdClient\FbConnectionInternal.cs, line 298) has incorrect condition:

            public void TransactionUpdated\(\)
	\{
		for \(int i = 0; i < this\.preparedCommands\.Count; i\+\+\)
		\{
			if \(\!this\.preparedCommands\[i\]\.IsAlive\)
				continue;

			FbCommand command = this\.preparedCommands\[i\]\.Target as FbCommand; //<<<= may be a null

			if \(command\.Transaction \!= null\) //<<<= potential NRE\. Correct code is: command \!= null && command\.Transaction \!= null
			\{
				command\.CloseReader\(\);
				command\.Transaction = null;
			\}
		\}
	\}

=>

Implementation of FirebirdSql.Data.FirebirdClient.FbConnectionInternal.TransactionUpdated function (FirebirdClient\FbConnectionInternal.cs, line 298) has incorrect condition:
{code}
public void TransactionUpdated()
{
for (int i = 0; i < this.preparedCommands.Count; i++)
{
if (!this.preparedCommands[i].IsAlive)
continue;

			FbCommand command = this\.preparedCommands\[i\]\.Target as FbCommand; //<<<= may be a null

			if \(command\.Transaction \!= null\) //<<<= potential NRE\. Correct code is: command \!= null && command\.Transaction \!= null
			\{
				command\.CloseReader\(\);
				command\.Transaction = null;
			\}
		\}
	\}

{code}

@firebird-automations
Copy link
Author

Modified by: Alex Gaysinskiy (gasizdat)

description: Implementation of FirebirdSql.Data.FirebirdClient.FbConnectionInternal.TransactionUpdated function (FirebirdClient\FbConnectionInternal.cs, line 298) has incorrect condition:
{code}
public void TransactionUpdated()
{
for (int i = 0; i < this.preparedCommands.Count; i++)
{
if (!this.preparedCommands[i].IsAlive)
continue;

			FbCommand command = this\.preparedCommands\[i\]\.Target as FbCommand; //<<<= may be a null

			if \(command\.Transaction \!= null\) //<<<= potential NRE\. Correct code is: command \!= null && command\.Transaction \!= null
			\{
				command\.CloseReader\(\);
				command\.Transaction = null;
			\}
		\}
	\}

{code}

=>

Implementation of FirebirdSql.Data.FirebirdClient.FbConnectionInternal.TransactionUpdated function (FirebirdClient\FbConnectionInternal.cs, line 298) has incorrect condition:

            public void TransactionUpdated\(\)
	\{
		for \(int i = 0; i < this\.preparedCommands\.Count; i\+\+\)
		\{
			if \(\!this\.preparedCommands\[i\]\.IsAlive\)
				continue;

			FbCommand command = this\.preparedCommands\[i\]\.Target as FbCommand; //<<<= may be a null

			if \(command\.Transaction \!= null\) //<<<= potential NRE\. Correct code is: command \!= null && command\.Transaction \!= null
			\{
				command\.CloseReader\(\);
				command\.Transaction = null;
			\}
		\}
	\}

@firebird-automations
Copy link
Author

Modified by: Alex Gaysinskiy (gasizdat)

description: Implementation of FirebirdSql.Data.FirebirdClient.FbConnectionInternal.TransactionUpdated function (FirebirdClient\FbConnectionInternal.cs, line 298) has incorrect condition:

            public void TransactionUpdated\(\)
	\{
		for \(int i = 0; i < this\.preparedCommands\.Count; i\+\+\)
		\{
			if \(\!this\.preparedCommands\[i\]\.IsAlive\)
				continue;

			FbCommand command = this\.preparedCommands\[i\]\.Target as FbCommand; //<<<= may be a null

			if \(command\.Transaction \!= null\) //<<<= potential NRE\. Correct code is: command \!= null && command\.Transaction \!= null
			\{
				command\.CloseReader\(\);
				command\.Transaction = null;
			\}
		\}
	\}

=>

Implementation of FirebirdSql.Data.FirebirdClient.FbConnectionInternal.TransactionUpdated function (FirebirdClient\FbConnectionInternal.cs, line 298) has incorrect condition:

            public void TransactionUpdated\(\)
	\{
		for \(int i = 0; i < this\.preparedCommands\.Count; i\+\+\)
		\{
			if \(\!this\.preparedCommands\[i\]\.IsAlive\) //<<<= This check does nothing\. Between this line and the following can happen garbage collection\.
				continue;

			FbCommand command = this\.preparedCommands\[i\]\.Target as FbCommand; //<<<= may be a null

			if \(command\.Transaction \!= null\) //<<<= potential NRE\. Correct code is: command \!= null && command\.Transaction \!= null
			\{
				command\.CloseReader\(\);
				command\.Transaction = null;
			\}
		\}
	\}

@firebird-automations
Copy link
Author

Modified by: @cincuranet

Link: This issue relate to DNET617 [ DNET617 ]

@firebird-automations
Copy link
Author

Commented by: @cincuranet

Sure it is, thanks. Looks like the DNET617 is related. I'll investigate.

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => In Progress [ 3 ]

@firebird-automations
Copy link
Author

Modified by: @cincuranet

Link: This issue relate to DNET605 [ DNET605 ]

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: In Progress [ 3 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: vNext [ 10704 ]

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

No branches or pull requests

2 participants