[Mono-bugs] [Bug 76494][Min] New - Mono.Data.SqliteClient Memory corruption when reusing connection after DELETE with named parameters

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Thu Oct 20 20:26:46 EDT 2005


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by tekhedd at byteheaven.net.

http://bugzilla.ximian.com/show_bug.cgi?id=76494

--- shadow/76494	2005-10-20 20:26:46.000000000 -0400
+++ shadow/76494.tmp.22968	2005-10-20 20:26:46.000000000 -0400
@@ -0,0 +1,110 @@
+Bug#: 76494
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: Gentoo 2.6.11 (crappy mobile celeron) / mono 1.1.9.2
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Minor
+Component: Sys.Data
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: tekhedd at byteheaven.net               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Mono.Data.SqliteClient Memory corruption when reusing connection after DELETE with named parameters
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+
+This is only a problem with sqlite version 3.
+
+glibc reports memory corruption (double free, but it varies) on a select
+with named parameters. This only happens where a previous SqliteCommand
+object has been Disposed using the same connection. (Like if you use a
+transaction to clear out a table and insert some new values. Which is what
+I was doing.)
+
+Steps to reproduce the problem:
+
+Build/run this program (based on kamil's bug report for a completely
+separate problem!)
+
+// To create db from the command line: 
+// sqlite3 SqliteTest.db "CREATE TABLE employee (firstname varchar(10),
+lastname varchar (10))"
+// build and run
+// mcs -r:System.Data -r:Mono.Data.SqliteClient Test.cs
+
+ using System;
+ using System.Data;
+ using Mono.Data.SqliteClient;
+ 
+ public class Test 
+ {
+    public static void Main(string[] args)
+    {
+       string connectionString = "URI=file://SqliteTest.db, Version=3";
+
+       SqliteConnection dbcon = new SqliteConnection(connectionString);
+       dbcon.Open();
+
+       // If you do a DELETE, dispose the command, then do a SELECT with
+       // parameters, double-free. No problem with the UPDATE.
+
+       SqliteCommand dbcmd = (SqliteCommand)dbcon.CreateCommand();
+       // dbcmd.CommandText = "UPDATE employee SET firstname='Kamil' ";
+       dbcmd.CommandText = "DELETE FROM employee";
+       dbcmd.ExecuteNonQuery();
+
+       // Comment this out: no memory corruption
+       dbcmd.Dispose();
+
+       dbcmd = dbcon.CreateCommand();
+       dbcmd.CommandText = 
+          "SELECT firstname, lastname FROM employee WHERE firstname = :parm";
+      
+       dbcmd.Parameters.Add (":parm", DbType.String).Value = "tekHedd";      
+
+       IDataReader reader = dbcmd.ExecuteReader();
+       while(reader.Read()) {
+            string FirstName = (string) reader[0];
+            string LastName = (string) reader[1];
+            Console.WriteLine("Name: " + 
+                FirstName + " " + LastName);
+       }
+       // clean up
+       reader.Close();
+       reader = null;
+       dbcmd.Dispose();
+       dbcmd = null;
+       dbcon.Close();
+       dbcon = null;
+    }
+ }       
+
+
+Actual Results:
+
+grindstone:~/testcase$ mcs -r:System.Data -r:Mono.Data.SqliteClient Test.cs
+grindstone:~/testcase$ mono --debug Test.exe
+*** glibc detected *** double free or corruption (out): 0x082c8738 ***
+Aborted
+
+Expected Results:
+Successful operation.
+
+How often does this happen? 
+Every time.
+
+Additional Information:
+
+You can work around the problem by not calling Dispose on the previous
+SqliteCommand object. Whether this will work outside of this minimal
+example, I do not know.
+
+I don't understand at all why this should result in memory problems.
+Perhaps related to nptl?


More information about the mono-bugs mailing list