Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
From: "Chris January" <chris@atomice.net>
To: "Boris Schaeling" <boriss@web.de>
Cc: "Cygwin@Cygwin.Com" <cygwin@cygwin.com>
Subject: RE: Bug in g++: Testcase exits with segmentation fault
Date: Tue, 14 Jan 2003 17:01:15 -0000
Message-ID: <LPEHIHGCJOAIPFLADJAHMEFIDDAA.chris@atomice.net>
MIME-Version: 1.0
Content-Type: text/plain;
	charset="Windows-1252"
Content-Transfer-Encoding: 7bit
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
In-Reply-To: <LOBBKDBPKEGJJFKNFHKBOELHIFAA.boriss@web.de>
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Importance: Normal


> The testcase attached to this mail compiled with g++ 2.95.3-10 or g++ 3.2
> 20020927 under Cygwin 1.3.18 exits with segmentation fault. It seems to be
> an error in g++ as the testcase doesn't work under Linux either.
> Can anyone
> help or do I have to report this error to the GCC website?
>
> BTW I found two ways to make the testcase work:
> 1) Change line 64 (and 70 respectively) and use "observer
> *Observer" instead
> of "std::list<observer>". I compiled the testcase with STLport-4.5.3 under
> Linux to see if it's a bug in the Standard Library but got again
> segmentation fault.
> 2) Remove line 75 which is a simple "poll(NULL, 0, 2000)". It
> works without
> this line but I don't know why.

The bug is actually in your testcase.
The line:
	Observers.push_back(observer());
creates a temporary observer object. So when the line
	observer::observer() { Select.give(this); }
calls give(), it leaves a dangling pointer.

Chris


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

