| delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-SWARE-Spam-Status: | No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS |
| X-Spam-Check-By: | sourceware.org |
| Message-ID: | <4B161962.3090108@gmail.com> |
| Date: | Wed, 02 Dec 2009 07:38:10 +0000 |
| From: | Dave Korn <dave DOT korn DOT cygwin AT googlemail DOT com> |
| User-Agent: | Thunderbird 2.0.0.17 (Windows/20080914) |
| MIME-Version: | 1.0 |
| To: | cygwin AT cygwin DOT com |
| Subject: | Re: odd segfault with my c program using cygwin 1.7 |
| 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> |
| In-Reply-To: | <416096c60912012235h2e5290c3q4ad720134d4f0422@mail.gmail.com> |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.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 |
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.
Doesn't look like it does to me:
> for(j=0; j<6*72; j++) {
> //printf("joe %d\n", j);
> string[j] = '\0';
> }
That's less than 432, not less than or equal.
It ran to completion on my machine without a problem. I tried it without
any -O option, and at -O{0,2,3} without any problem. I ran it under gdb and
set a watchpoint on string[432] and it ran without tripping. So I don't know
what's going wrong for OP.
cheers,
DaveK
--
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
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |