This is the mail archive of the cygwin@cygwin.com 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: Re: BUG - Cygwin to GNU CC compatibility


On Tue, 6 Aug 2002, Arash Partow wrote:

> Hi Igor,
> this is the output from your modified version.
> I will have a more lengthier replay by this evening :D
> (as you can see it didn't crash :D )

Arash,
I didn't claim it would...

> yallara.cs.rmit.edu.au% ./countertest
> DigitList(): digitList=42b18
> DigitList(): digitList=0
> DigitList(): digitList=42b18
> loadDigitList(): digitList=42b30
> ~DigitList(): freeing digitList=42b18		<-
> ~DigitList(): freeing digitList=42b18		<-
> DigitList(): digitList=42b18
> DigitList(): digitList=0
> DigitList(): digitList=42b18
> loadDigitList(): digitList=42b48
> ~DigitList(): freeing digitList=42b18		<-
> ~DigitList(): freeing digitList=42b18		<-
> DigitList(): digitList=42b18
> DigitList(): digitList=0
> DigitList(): digitList=42b18
> loadDigitList(): digitList=42b60
> ~DigitList(): freeing digitList=42b18		<-
> ~DigitList(): freeing digitList=42b18		<-
> Number of digits: 3
> Number of digits: 3
> Number of digits: 3
> yallara.cs.rmit.edu.au%

Note the arrows above.  You're freeing THE SAME piece of memory multiple
times, and using it afterwards.  Once you free something, the memory
manager is welcome to do whatever it wants with it, including zeroing the
memory.  The fact that it doesn't happen on the machine named yallara
(which, I presume, is a linux machine) just means you're lucky, but
doesn't mean you don't have a bug.

If you want to make sure you do have a bug, zero out the digitList array
before freeing it, and see if your program still runs correctly.
	Igor
P.S.  My message was sent to the list (notice the Reply-To: below).  I'm
forwarding my reply to the list as well.  Please send all communications
regarding this topic to the cygwin list.

> >From: Igor Pechtchanski <pechtcha@cs.nyu.edu>
> >Reply-To: cygwin@cygwin.com
> >To: Arash Partow <arashp@hotmail.com>
> >CC: cygwin@cygwin.com
> >Subject: Re: Re: BUG - Cygwin to GNU CC compatibility
> >Date: Mon, 5 Aug 2002 21:58:50 -0400 (EDT)
> >MIME-Version: 1.0
> >Received: from [128.122.20.14] by hotmail.com (3.2) with ESMTP id
> >MHotMailBF18785A00144004315B807A140ECA520; Mon, 05 Aug 2002 18:58:51 -0700
> >Received: from localhost (pechtcha@localhost)by slinky.cs.nyu.edu
> >(8.11.6+Sun/8.11.6) with ESMTP id g761woK01363;Mon, 5 Aug 2002 21:58:50
> >-0400 (EDT)
> >From pechtcha@cs.nyu.edu Mon, 05 Aug 2002 19:00:24 -0700
> >X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing
> >-bs
> >In-Reply-To: <F1813ooYFbW7xV2zLwF0001ed5a@hotmail.com>
> >Message-ID: <Pine.GSO.4.44.0208052123380.694-101000@slinky.cs.nyu.edu>
> >
> >On Tue, 6 Aug 2002, Arash Partow wrote:
> >
> > > Hi Ernest,
> > >
> > > >If your program runs on a bunch of systems, well, you're just lucky,
> > > >because the bugs are in your code, not in cygwin.
> > >
> > > i doubt the efforts of the cygwin group can surpass those of borland
> > > and GCC and now after recieving your mail visual c++
> > > It seems that all these systems can produce perfectly running
> > > executables, running both on linux, solaris and windows.
> > >
> > > I don't think there is any luck involved in this, there is a bug and it
> > > needs to be fixed. out of the 4 compilers i compiled this code on only
> > > cygwin was the one to fail.
> >
> >Arash,
> >Whether a code with dangling pointers fails depends solely on the
> >implementation of the memory manager.  Some memory managers try not to
> >reuse memory as much, and thus, even if you free a pointer, the memory
> >may not be overwritten for short running programs, and using a dangling
> >pointer produces a semblance of correct operation.  However, failing to
> >run buggy programs is not in itself a bug.  A suggestion would be to try
> >to introduce a 'ulimit -m 5k' (or some other small value, so that your
> >free list becomes more of a bottleneck) on linux and try to run your
> >program again.  Unless the linux developers can work miracles, you can
> >limit the memory enough that free list entries become reused, and your
> >program will fail.
> >
> >I won't reply to the rest, except to say I fully agree with everyone who
> >said your code is buggy, and I intend to prove it.
> >
> > > [snip: a long defense of incorrect concepts and code]
> > >
> > > no two objects are using digitList, hence no crossing over into the
> > > twilight-zone.
> >
> >:-D  Just you wait...
> >I've added printfs to your code to print the pointer value of the
> >digitList field whenever it's assigned, and just before it's freed.  This
> >should prove very illuminating.  Sit back and watch.  A zip is attached.
> >	Igor
> >--
> >				http://cs.nyu.edu/~pechtcha/
> >       |\      _,,,---,,_		pechtcha@cs.nyu.edu
> >ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
> >      |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski
> >     '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!
> >
> >It took the computational power of three Commodore 64s to fly to the moon.
> >It takes a 486 to run Windows 95.  Something is wrong here. -- SC sig file
> >
> ><< arash_bug.zip >>
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

It took the computational power of three Commodore 64s to fly to the moon.
It takes a 486 to run Windows 95.  Something is wrong here. -- SC sig file


--
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/


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