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

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: file max sizes?
Date: Sun, 09 Mar 1997 17:17:56 -0800
Organization: Two pounds of chaos and a pinch of salt
Lines: 53
Message-ID: <33236144.2A78@cs.com>
References: <01bc2ca1$660fce80$31c9c2d0 AT bonk>
Reply-To: fighteer AT cs DOT com
NNTP-Posting-Host: ppp104.cs.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Jeffrey A Studer wrote:
> 
> I am very new to djgpp so pardon my ignorance.   I have been opening and
> trying to read a file using open, and read.  I was wondering if there is a
> maximum size of file that can be opened or read from.  it seems that
> reading 40 bytes from a file at once, occasionally gives a SIGSEGV fault at
> runtime ( I wish i knew what these runtime error messages meant, as well.
> Is there a FAQ on DOS error messages? ).  I WAS trying to read a minimum of
> 280 bytes, in one pass.  I will resort to reading 4 bytes at a time ,
> unless someone can assist me.

This doesn't make any sense at all to me.  :)  I have written programs
that grab huge chunks of files at a time and have never gotten a SIGSEGV
as a result.  Because of the way the internal mechanisms of the DPMI
host work, the most efficient buffer size to use when reading files is
the size of the transfer buffer, which is usually 16k.  If I can move
16k buffers around, you shouldn't be having trouble with 280 bytes!

Some tips on debugging - that big dump of numbers you get when a program
crashes is a stack traceback of the program's state at the moment of the
crash.  If you've compiled your program with debugging information ('-g'
switch), you can use the 'symify' utility that comes with DJGPP to turn
the traceback into a readable display of where your program was when it
crashed.  Symify must be used while the traceback is still on the
screen.

If this doesn't help you find the bug, please post a sample of the
offending code that is sufficient to cause the error and we'll try to
debug it for you.  A copy of the stack dump that the program prints when
it crashes would also help.  But here are some things to consider:

 - Make sure you are initializing all your pointers.
 - Large numbers of calls to malloc() (as in, thousands) can cause
problems with the CWSDPMI DPMI host that DJGPP uses.  For a fix, read
the file 'cwsparam.doc'.
 - Always check the return value of functions like fread() to make sure
the read operation worked!  If it didn't, test the 'errno' global
variable to find out why.
 - Make sure you are opening the file in the right mode.
 - If you are reading data into a structure, you may need to experiment
with struct packing - look in the FAQ and the gcc docs for more info.

Good luck!

-- 
John M. Aldrich, aka Fighteer I <fighteer AT cs DOT com>

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d- s+:- a-->? c++>$ U@>++$ p>+ L>++ E>++ W++ N++ o+>++ K? w(---)
O- M-- V? PS+ PE Y+ PGP- t+(-) 5- X- R+(++) tv+() b+++ DI++ D++ G>++
e(*)>++++ h!() !r !y+()
------END GEEK CODE BLOCK------

- Raw text -


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