From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b6c392d1e6028229,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news3.google.com!feeder.news-service.com!newsfeed.straub-nv.de!nuzba.szn.dk!news.szn.dk!pnx.dk!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail Date: Sat, 29 Jan 2011 12:33:52 +0100 From: =?ISO-8859-1?Q?Thomas_L=F8cke?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101210 Thunderbird/3.1.7 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Memory leak in GNATcoll or false positive from valgrind? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <4d43fb20$0$23765$14726298@news.sunsite.dk> Organization: SunSITE.dk - Supporting Open source NNTP-Posting-Host: 83.91.213.86 X-Trace: news.sunsite.dk DXC=?jHVi2A58;Lc5QH[6O^X]LYSB=nbEKnkK:0HF:[2V9bJ1GQX8;5?CnGRED9SjB8:6IQo^8G8>AndMMiBCi7GS^CFd< Hey all, I'm using this to connect to my PostgreSQL server: function Database_Connection_Factory (Desc : in GNATCOLL.SQL.Exec.Database_Description) return GNATCOLL.SQL.Exec.Database_Connection is use GNATCOLL.SQL.Exec; use GNATCOLL.SQL.Postgres; DBMS : constant String := Get_DBMS (Desc); begin if DBMS = DBMS_Postgresql then return Build_Postgres_Connection (Desc); else return null; end if; end Database_Connection_Factory; declare DB_Descr : GNATCOLL.SQL.Exec.Database_Description; DB : SQL.Exec.Database_Connection; C1 : SQL.Exec.Forward_Cursor; begin GNATCOLL.SQL.Exec.Setup_Database (Description => DB_Descr, Database => "my_database", User => "my_user", Host => "my_host", Password => "my_password", DBMS => GNATCOLL.SQL.Exec.DBMS_Postgresql, SSL => GNATCOLL.SQL.Exec.Prefer); DB := GNATCOLL.SQL.Exec.Get_Task_Connection (Description => DB_Descr, Factory => Database_Connection_Factory'Access); C1.Fetch (Connection => DB, Query => "select * from some_table"); while C1.Has_Row loop Put_Line (C1.Value (Field => 1)); C1.Next; end loop; DB1.Commit_Or_Rollback; end; And it is working a charm, except that valgrind is reporting a leak when I'm running it: http://pastebin.com/z66U5YAQ I can make the leak go away, if I call Get_Task_Connection from a dummy DB connection task that looks like this: task body DB_Conn is use GNATCOLL.SQL.Exec; begin loop select accept Fetch (Conn : out Database_Connection; Desc : in Database_Description) do Conn := Get_Task_Connection (Description => Desc, Factory => Database_Connection_Factory'Access); end Fetch; or terminate; end select; end loop; end DB_Conn; A mapping between the AWS tasks and the DB_Conn tasks are kept using the Ada.Task_Attributes package: package Task_Association is new Ada.Task_Attributes (DB_Conn_Access, null); This works, without a hitch. No leaks. Instead I get the annoying extra DB_Conn layer. I'd much rather just go straight to Get_Task_Connection from my AWS thread. So, is this valgrind reporting a false positive, or am I doing something wrong? The above happens with GNATcoll (gnatlib) SVN revision 169867. -- Thomas L�cke Email: tl at ada-dk.org Web: http//:ada-dk.org http://identi.ca/thomaslocke