delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/09/01/18:18:40

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <43177F3F.5278D950@dessent.net>
Date: Thu, 01 Sep 2005 15:22:55 -0700
From: Brian Dessent <brian AT dessent DOT net>
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: BUG report: destructor exception vector<bool>; DLL 1.5.18
References: <431775C6 DOT 7040609 AT sdl DOT com>
X-IsSubscribed: yes
Reply-To: cygwin AT cygwin DOT com

Andreas wrote:

> I compiled the same file on a LINUX system, it runs there without a problem.

That is a very poor way to assume that your code is correct.  When you
make coding errors that trash memory, any one of a number of things can
happen and the outcome completely depends on the compiler, the operating
system, and so on.  In other words, just because it doesn't segfault on
linux doesn't mean it's correct.

> ============================
> here is cygcheck -s -v -r > cygcheck.out
> ============================

In the future please attach these, instead of including them inline.  It
makes your message easier to read and it makes the archives much more
clean.

>     int idx = p->nameIdx.getIdx(name);
>     p->checked[idx]=true;

And here is your bug.  If 'name' does not exist in the list, getIdx()
returns -1.  Since you don't check this value, you try to set
checked[-1]=true, which is out of bounds and an undefined operation. 
From here on out your program is uncharted waters - it could crash, it
could run perfectly, it could do anything.  In this case it's probably
stomping on some part of the vtable which is why it dies when the
destructor is run.

If you add a test for idx == -1 to the code it runs fine with no
segfault.

Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019