cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/28/23:16:20

From: bluehyacinth AT usa DOT net (Samuel)
Newsgroups: comp.os.msdos.djgpp
Subject: Runtime error with simple program. Please help!
Date: Fri, 29 May 1998 01:10:08 GMT
Organization: Vision Online
Lines: 77
Message-ID: <356f0ae0.987008@news.vol.net>
NNTP-Posting-Host: c11-21.vol.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

I'm learning C now and use DJGPP as the compiler for
the exercises I do. Everything went fine until I go to
array. 

I compiled the exercise using "gcc -o ex4.exe ex4.c".
The compiler reported no error found. But when I run
the executable, (both under the win95 dos box and real
dos 6.20 with cwsdpmi), I got the following runtime error:

======================================================
F:\work>ex4
Exiting due to signal SIGSEGV
General Protection Fault at eip=0000009f
eax=000000b8 ebx=0000000a ecx=00000063 edx=0010a430 esi=0000006e
edi=0010a458
ebp=0010a4a8 esp=0010a414 program=F:\WORK\EX4.EXE
cs: sel=00a7  base=836c7000  limit=0011ffff
ds: sel=00af  base=836c7000  limit=0011ffff
es: sel=00af  base=836c7000  limit=0011ffff
fs: sel=0087  base=00008f70  limit=0000ffff
gs: sel=00c7  base=00000000  limit=ffffffff
ss: sel=00af  base=836c7000  limit=0011ffff

Call frame traceback EIPs:
  0x0000009f
  0x00001fca

F:\work>
======================================================

The program I wrote for exercise is really really simple.
I don't understand why I got such an error. I did a search
in the faq that came with the package for SIGSEGV, but what
I found didn't solve my problem. The DJGPP I used is 2.01

Please help.

Thanks!!

ps the source code
------------------------------------------------------

#include <stdio.h>
#include <crt0.h>

unsigned _stklen = 1048576;  /* need a 1MB stack */      
int _crt0_startup_flags = _CRT0_FLAG_FILL_SBRK_MEMORY;

/* the above two lines were added after reading the faq  */
/* but didn't solve the problem; probably the situation  */
/* described in the faq wasn't the same as mine.         */

int main()
{
    int array1[10], array2[10], arrays[10];
    int index;

    for (index = 0; index <= 9; index = index + 1)
    {
        array1[index] = (index + 1) * (index + 1);
        array2[index] = index + 1;
    }

    for (index = 0; index <= 9; index = index + 1)
        arrays[index] = array1[index] + array2[index];

    prinft(" index   array1   array2   arrays\n");    /* print the
header */
    prinft("======= ======== ======== ========\n");

    for (index = 0; index <= 9; index++)
         prinft("%4d    %5d    %5d    %5d    \n",index, array1[index],
array2[index], arrays[index]);
    
    return 0;
}
------------------------------------------------------

- Raw text -


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