delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/12/02/02:46:31

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
In-Reply-To: <4B161962.3090108@gmail.com>
References: <20071202162155 DOT XNVY20104 DOT mta10 DOT adelphia DOT net AT dual-xeon DOT weasel DOT com> <20091202013344138 DOT XZWP20286 AT cdptpa-omta02 DOT mail DOT rr DOT com> <416096c60912012235h2e5290c3q4ad720134d4f0422 AT mail DOT gmail DOT com> <4B161962 DOT 3090108 AT gmail DOT com>
Date: Wed, 2 Dec 2009 07:46:20 +0000
Message-ID: <416096c60912012346j43db4597j2590fa3d9e93ffb7@mail.gmail.com>
Subject: Re: odd segfault with my c program using cygwin 1.7
From: Andy Koppe <andy DOT koppe AT gmail DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
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

2009/12/2 Dave Korn:
> Andy Koppe wrote:
>> 2009/12/2 jeffunit:
>>> My program ran fine under cygwin 1.5 as well as many versions of linux
>>> including
>>> mandriva 2009, mandriva 2009.1 and mandriva 2010.0
>>>
>>> When compiled with
>>> gcc cal.c -o cal
>>> and run with
>>> cal 2009
>>> I get a segmentation fault.
>>> When I uncomment line 62, the program runs successfully.
>>
>> It's the line after that that has the bug: it's writing to index 432
>> of a 432-element array.
>
> =C2=A0Doesn't look like it does to me:
>
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 for(j=3D0; j<6*72; j++) {
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 //printf("joe %d\n", j);
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 string[j] =3D '\0';
>> =C2=A0 =C2=A0 =C2=A0 }
>
> =C2=A0That's less than 432, not less than or equal.

You're right, somehow I'd completely misread that, thinking that the
string[j]=3D'\0' is outside the loop.

Sorry,
Andy

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

- Raw text -


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