delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/18/01:03:47

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Need some help ! When I try to read a file it says SIGSEGV error
Date: Fri, 17 Oct 1997 22:56:37 +0000
Organization: Two pounds of chaos and a pinch of salt
Lines: 48
Message-ID: <3447ED25.4762@cs.com>
References: <xhoul04 DOT 25 DOT 00107906 AT vse DOT cz>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp224.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Houska Ludek - IN wrote:
> 
>    Recently I downloaded the DJGPP. When I try to read simple file it says
> only SIGSEGV error. ( I use fscanf( file, "%d", &number ) and the file looks
> like this :
> 3 1 2 2 2 2
> 
> - only numbers, the program runs through the cycle( read one number ) two
> times, and then it crashes. The value from the file doesn't even get into
> the variable.

You should post some sample code from your program.  SIGSEGV usually
indicates some sort of bad memory access, such as an unitialized
pointer.  It's impossible to say exactly what you're doing wrong,
however, without seeing your code.

In the meantime, you can try using some of the excellent debugging tools
that come with DJGPP.  The simplest thing you can do is compile your
program with the '-Wall' parameter; this will cause gcc to produce a
variety of warnings indicating potential programming errors.  Another
good way to find problems is to compile with the '-g' parameter and then
run 'symify <yourprog.exe>' when the crash traceback is on the screen. 
This will tell you where the program crashed so you can determine what
possibly went wrong.  For more advanced debugging, you can use 'gdb', a
command-line debugger availabe in the same place you got DJGPP.  If you
use the RHIDE IDE, it features an integrated debugger similar to
Borland's Turbo Debugger, but based on gdb.

Look for the following things:

- attempting to access an unitialized or NULL pointer.
- attempting to read past the end of the file.
- failing to make sure that the file open command succeeded.
- failing to close the file (or closing it unnecessarily).
- bad/erroneous characters in the file.
- incorrect memory allocation calls.
- implicit function declarations (omitting header files).

You can see how general these suggestions are.  The best way to get help
is to post some of the code.

-- 
---------------------------------------------------------------------
|      John M. Aldrich       | "It may be better to be a live jackal|
|       aka Fighteer I       | than a dead lion, but it is better   |
|   mailto:fighteer AT cs DOT com   | still to be a live lion."            |
| http://www.cs.com/fighteer |                - Lazarus Long        |
---------------------------------------------------------------------

- Raw text -


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