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
Null reference exception on fbcommand dispose [DNET316] #327
Comments
Commented by: Gerdus van Zyl (angelblaze) Forgot to mention the exception isn't catchable, as in visual studio does not jump to the line in my program that gave the exception. |
Commented by: Marc Bettex (mbettex) I observed the same behavior. I don't know really what caused it in my case. It seems to happen kind of randomly, but it only when I have several threads that use the connector to query the database at the same time. It seems that the FbConnectionInternal.preparedCommands field is cleared during the execution of the FbConnectionInternalRemovePerparedCommand, which causes an exception because the variable i is greater than zero but the size of the collection is zero. I would have thought that this field was modified by another thread, but I'm not sure. I don't understand how another thread could modify this field, since it is the garbage collector that calls this method when the exception occurs, and it shouldn't be possible to use an object while it is being garbage collected. But I don't really see how the code in the loop could clear this field either. So yeah, I don't really have a clue of why this happens. It looks like very strange to me. If you want to catch the exception in visual studio, type CTR + ALT + E in visual studio and check everything in the dialog. Then if the exception is thrown, the debugger will stop at this point. EDIT: Actually, after spending some more time, I found a place where I forgot to call dispose() on an FbCommand in my code. After adding that call and running tests that used to fail sometimes before, they don't fail anymore. It used to happen kind of randomly, so I cannot be sure that the problem is really solved, but it seems to work now. So yeah, Gerdus van Zyl is probably right when saying that the problem is caused by not calling dispose() an an FbCommand before the connection is closed. |
Commented by: Eugeniy (hev) Same problem. But during work with Entity Framework. Problems with reproduction. Such kind of problems prevent from using of Firebird in any real .NET projects based on Entity Framework. Handling errors in some specific command/query may have work-around. But such kind of errors like this one don't have realistic work-around. I think that priority should be changed to Blocker or Critical. |
Commented by: Martin Turek (jskeletti) I get sometimes a strange error while I use a program which was created with provider 2.5.1. Now I changed the version to 2.6 and get following error spontaneously, I can't say when and why it happens. Maybe you will know. It seems not to be cause by my application, in addition to that this error does not occur when I use the old provider version. Error (sorry, but in german): [4208] LPCS->Unhandled EXCEPTION -> OnCurrentDomain_UnhandledException |
Commented by: Gerdus van Zyl (angelblaze) recently upgraded to 2.6.5 in conjunction with .net version 4 and problem still exists. The problem is intermittent as all good heisenbugs should be. |
Commented by: Gerdus van Zyl (angelblaze) updated to inform that bug still exist in newest version and in .net4/vs2010 |
Modified by: Gerdus van Zyl (angelblaze)Version: 2.6 [ 10371 ] environment: Windows 7, .net 3.5 sp1, visual studio 2008 => Windows 7, .net 3.5 sp1, visual studio 2008 |
Commented by: Mert Ali Özalp (mert19) I am using http://asp.net 4.0 and firebird 2.5 in my web site project. And i use firebird .net provider (for sure) My web site is being used by only 5 - 10 users by now. I tried .net provider 2.5.2 and 2.6.5 but for both of them, I am getting the following exception for most of the time .... Exception: System.NullReferenceException Message: Object reference not set to an instance of an object. StackTrace: at FirebirdSql.Data.FirebirdClient.FbCommand.RollbackImplicitTransaction() Description: The process was terminated due to an unhandled exception. But when only one user is using the site , no exception occurs, and when a second user enters the site, just at that time the exception occurs and goes on occurring as long as more than one user is using the site. I think there is problem in the user session management mechanism of the firebird .net provider ... Could any one give me any advice or solution for this problem ? |
Commented by: Can A. Course (canacourse) Happening to me as well but I am calling dispose() or using usings in the right places. Very random and hard to track down. |
Modified by: @cincuranetstatus: Open [ 1 ] => Resolved [ 5 ] resolution: Fixed [ 1 ] Fix Version: 2.7 [ 10431 ] |
Modified by: @cincuranet |
Modified by: @cincuranet |
Commented by: Leonard Wennekers (l.wennekers) We are using FB 2.5.1 with the provider 2.7. 7 in a Windows 7, .net 4, visual studio 2010 |
Commented by: Andrey (andrew_1985) It still appears in NETProvider-3.0.2.0-NET40.7z with FB 2.5!! It is so frustrating |
Commented by: @cincuranet Provide a test case. |
Commented by: Yiannis Bourkelis (yiannis) I am also experiencing the same issue. The error message I get is: ################## Stack Trace: This error pops up randomly, once every one or two days and causes my app to crash. I am using firebird net provider 2.7.7, targeting net framework 2.0. Any ideas how to fix this? |
Commented by: Bill Volz (billvolz) Making sure that all your command & connection objects are wrapped in using tags will prevent this from occurring. i.e. using(var conn = new FbConnection()) If you want to reproduce this error create an IIS http://Asp.net web application that uses the provider but don't call dispose on the objects. It may take a few attempts for it to occur but it will eventually occur. |
Commented by: Yiannis Bourkelis (yiannis) Thank you Bill, I will try your suggestion. If you have a working solution to reproduce this issue please post it here so that Jiri will be able to fix it. I will also try to create a winforms reproducable test case and post it here |
Commented by: Yiannis Bourkelis (yiannis) Finally I was able to create a reproducable case for this exception. Steps to reproduce: Inside the zip file you will find the folder FirebirdNullExceptionReproduce. Run the app and wait for some seconds. System.NullReferenceException or System.AccessViolationException |
Modified by: Yiannis Bourkelis (yiannis)Attachment: FirebirdNullExceptionReproduce.zip [ 12410 ] |
Submitted by: Gerdus van Zyl (angelblaze)
Is duplicated by DNET368
Is duplicated by DNET386
Attachments:
FirebirdNullExceptionReproduce.zip
Votes: 6
I have been getting the following exception if I close an connection (or forget to close connection manually) before explicitly calling .Dispose() on all FbCommands created (I now put fbcommand object in a list and dispose of manually before connection close). Which is strange since I can't see where I keep die commands alive beyond the life of the connection. The part of my program which gives the problem is a database schema upgrade that runs in a background thread.
Object reference not set to an instance of an object.
stack trace:
at FirebirdSql.Data.FirebirdClient.FbConnectionInternal.RemovePreparedCommand(FbCommand command)
at FirebirdSql.Data.FirebirdClient.FbCommand.Release()
at FirebirdSql.Data.FirebirdClient.FbCommand.Dispose(Boolean disposing)
at System.ComponentModel.Component.Finalize()
target site:
{Void RemovePreparedCommand(FirebirdSql.Data.FirebirdClient.FbCommand)}
Commits: f71e5d8
The text was updated successfully, but these errors were encountered: