Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com From: "Dave Korn" To: Subject: RE: cygwin-gcc-fopen bug? Date: Fri, 10 Dec 2004 16:18:54 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit In-Reply-To: <20041210161422.GA2636@ingber.com> Message-ID: X-OriginalArrivalTime: 10 Dec 2004 16:18:55.0046 (UTC) FILETIME=[F1DCC660:01C4DED3] > -----Original Message----- > From: cygwin-owner On Behalf Of Lester Ingber > Sent: 10 December 2004 16:14 > I have a good-sized vanilla-C code that was running just fine a month > or two ago under XPPro/Cygwin and under SPARC/Solaris9, and STILL runs > just fine under SPARC/Solaris9. > All my other Cygwin files are the most current. I use gcc OR g++ to > run my code, with OR without -mno-cygwin, and they were running fine a > month or two ago. > > My C code under Cygwin (not under Solaris9) now bombs after 4 calls to > if ((ptr_positions = fopen (dataFile, "r")) == NULL) { > ... > Under DDD I can see that dataFile has gotten mangled and a NULL is now > in the middle of its name. > > I tried this again, using the DOS cmd to replace cygwin1.dll with the > most current (not the snapshot cygwin1-20041117.dll), and now the code > bombs at the very first use of fopen, a DIFFERENT place than above: > if ((Portfolio->ptr_err = fopen (infoFile, "a")) == NULL) { > ... > > Any suggestions would be appreciated. Your code has a bug: a stray pointer or array overwrite that is trashing some memory. The only reason you get away with it on Solaris is by sheer luck; either the stack or heap layout is different, or the random uninitialised contents of a variable point somewhere harmless or something like that. Since you can see a NUL (heh, NULL != NUL you know!) appearing in the middle of the name string, you could always set a gdb watchpoint on it to see exactly when it gets stomped and what instruction is doing it. cheers, DaveK -- Can't think of a witty .sigline today.... -- 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/