[Mono-bugs] [Bug 333746] New: Possible bug with garbage collection (NHibernate example)

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Oct 14 18:06:14 EDT 2007


https://bugzilla.novell.com/show_bug.cgi?id=333746

           Summary: Possible bug with garbage collection (NHibernate
                    example)
           Product: Mono: Runtime
           Version: 1.2
          Platform: i586
        OS/Version: Linux
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: GC
        AssignedTo: lupus at novell.com
        ReportedBy: emarkp at hotmail.com
         QAContact: mono-bugs at ximian.com
          Found By: ---


Created an attachment (id=178314)
 --> (https://bugzilla.novell.com/attachment.cgi?id=178314)
All files needed to reproduce this bug.  The only change that should be needed
is the host name in the connection string.

Attatched is a simple project that demonstrates this issue.  All files needed
for execution are in the bin\Release\ folder.  You would need to rebuild the
app changing the host in the connection string.  Here are the queries to set up
the database, this can be ran inside the mysql client:

create database NHTest;
use NHTest;
CREATE TABLE users (
  LogonID nvarchar(20) NOT NULL default '0',
  Name nvarchar(40) default NULL,
  Password nvarchar(20) default NULL,
  EmailAddress nvarchar(40) default NULL,
  LastLogon datetime default NULL,
  PRIMARY KEY  (LogonID)
);
grant all on NHTest.* to 'nhtestuser'@'%' identified by 'nhtestpass';


When running this small test app on mono, I get the following error:

miles at trout:~/NHTest$ ./NHTest.exe

Unhandled Exception: System.NullReferenceException: Object reference not set to
an instance of an object
  at NHibernate.Transaction.AdoTransaction.AfterTransactionCompletion (Boolean
successful) [0x00000]
  at NHibernate.Transaction.AdoTransaction.Commit () [0x00000]
  at NHTest.Program.Main (System.String[] args) [0x00000]
miles at trout:~/NHTest$

This application runs fine using Microsoft's CLR.  

Here's the strange part, 

The function (In NHibernate.Transaction.AdoTransaction) throwing the
nullreference is: 



      private void AfterTransactionCompletion(bool successful) 
      { 
         session.AfterTransactionCompletion(successful, this); 
         session = null; 
         begun = false; 
      } 



And the only object being dereferenced anywhere is "session" 

Which is where the impossible seems to come in... because in the call stack
AdoTransaction.AfterTransactionCompletion is called directly from Commit which
looks like this: 


                public void Commit()
                {
                        CheckNotDisposed();
                        CheckBegun();

                        log.Debug("commit");

                        if (session.FlushMode != FlushMode.Never)
                        {
                                session.Flush();
                        }

                        session.BeforeTransactionCompletion(this);

                        try
                        {
                                trans.Commit();
                                committed = true;
                                AfterTransactionCompletion(true);
                                Dispose();
                        }
                        ...
<snip> 


Session is being dereferenced just fine well before Commit gets around to
calling AfterTransactionCompletion.  I've spent a little time reviewing the
code and it seems that no code between session.FlushMode and trans.Commit() in
the above snippet could set session to null.  I don't think this is a threading
issue because it happens very consistently.  The only thing that crosses my
mind is possibly a garbage collection issue, if somehow it considers that
session object marked for removal and then consistently decides to clean up for
some reason between those points in the code.  This could be a bug with
NHibernate's library that just never happens with the Microsoft CLR and
consistently happens with the mono implementation and if that's the case I
apologize for taking your time.


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list