From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26618 invoked by alias); 18 Apr 2011 15:25:02 -0000 Received: (qmail 26585 invoked by uid 22791); 18 Apr 2011 15:25:00 -0000 X-SWARE-Spam-Status: No, hits=-0.7 required=5.0 tests=AWL,BAYES_40,RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY X-Spam-Check-By: sourceware.org Received: from nm24.bullet.mail.sp2.yahoo.com (HELO nm24.bullet.mail.sp2.yahoo.com) (98.139.91.94) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Mon, 18 Apr 2011 15:24:44 +0000 Received: from [98.139.91.61] by nm24.bullet.mail.sp2.yahoo.com with NNFMP; 18 Apr 2011 15:24:43 -0000 Received: from [98.136.185.44] by tm1.bullet.mail.sp2.yahoo.com with NNFMP; 18 Apr 2011 15:24:43 -0000 Received: from [127.0.0.1] by smtp105.mail.gq1.yahoo.com with NNFMP; 18 Apr 2011 15:24:43 -0000 Received: from cgf.cx (cgf@96.252.118.15 with login) by smtp105.mail.gq1.yahoo.com with SMTP; 18 Apr 2011 08:24:42 -0700 PDT X-Yahoo-SMTP: jenXL62swBAWhMTL3wnej93oaS0ClBQOAKs8jbEbx_o- Received: from localhost (ednor.casa.cgf.cx [192.168.187.5]) by cgf.cx (Postfix) with ESMTP id 2DF1F4A801A for ; Mon, 18 Apr 2011 11:24:42 -0400 (EDT) Date: Mon, 18 Apr 2011 15:40:00 -0000 From: Christopher Faylor To: cygwin@cygwin.com Subject: Re: Memory leak in select Message-ID: <20110418152441.GA12913@ednor.casa.cgf.cx> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <4DAC23E3.2020005@lysator.liu.se> <4DAC2D35.5070106@lysator.liu.se> <4DAC4B6A.50101@lysator.liu.se> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4DAC4B6A.50101@lysator.liu.se> User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com X-SW-Source: 2011-04/txt/msg00245.txt.bz2 On Mon, Apr 18, 2011 at 04:32:10PM +0200, Peter Rosin wrote: >Den 2011-04-18 14:23 skrev Peter Rosin: >> Den 2011-04-18 13:43 skrev Peter Rosin: >>> Hi! >>> >>> Using the following STC, I'm seeing what appears to be a memory >>> leak in select(2). >>> >> ----------------8<---(selectleak.c)--------- >> #include >> #include >> >> int >> main(void) >> { >> fd_set fdset; >> >> long flags = fcntl(0, F_GETFL); >> fcntl(0, F_SETFL, flags | O_NONBLOCK); >> >> for (;;) { >> int res; >> char buf[20]; >> >> FD_ZERO(&fdset); >> FD_SET(0, &fdset); >> res = select(1, &fdset, NULL, NULL, NULL); >> if (!res) >> continue; >> if (res < 0) >> return 1; >> res = read(0, buf, sizeof(buf)); >> if (!res) >> break; >> if (res < 0) >> return 1; >> } >> >> return 0; >> } >> ----------------8<-------------------------- > >Ok, I'm taking a wild swing at this, and my guess is that the call >sel.cleanup () in cygwin_select prematurely zeros out the cleanup >member of the select_record. The call to sel.poll () then adds >"stuff" to the select_record that really should have been cleaned >up, but isn't since cleanup has already been executed and then >zapped (by select_stuff::cleanup). > >But what do I know? How does sel.poll add "stuff" that should be cleaned up? That function only looks for bits to set. cgf -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple