X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: Mark Geisert Subject: Re: strange bug that doesn't occur in Linux, OpenBSD or ITS Date: Sun, 19 Feb 2012 00:29:04 +0000 (UTC) Lines: 34 Message-ID: References: <1329589939 DOT 95502 DOT YahooMailNeo AT web120301 DOT mail DOT ne1 DOT yahoo DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit User-Agent: Loom/3.14 (http://gmane.org/) X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: 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 Jeremiah Bishop writes: > theĀ  bash commands used are: > 1) gcc "cygwin puzzle.c" > > 2) ./a.out a b > Now either version used on a file with a shorter set of lines, works just fine but strangely, that single > digit difference aborts the program without throwing any error on the sample input or text files with > similarly long lines. > > Perhaps that has been covered before but 3 hours of searching the archives did not yield any helpful results > [perhaps I used the wrong search criteria? ] > > any tips or hints on what has gone wrong will be helpful. 1. This has nothing to do with Cygwin, but rather basic programming safety practices: 2. You aren't checking the result of malloc() to see if it's NULL before using it. The heap (where malloc() gets its memory) is not infinite and varies in size between platforms. 3. You didn't say what happened when you ran the program, so I had to audit it and run it and watch it laboriously consume memory until I ran out of patience. 4. You've coded functions nested inside main(). I haven't seen that practice in C language before but apparently it works. Color me impressed. That's all I've got. HTH, ..mark -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple