This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: BUG report: destructor exception vector<bool>; DLL 1.5.18


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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]