GNU bug report logs - #2790
emacs 22.1.1 cannot open 5GB file on 64GB 64-bit Linux box

Previous Next

Package: emacs;

Reported by: Mike Coleman <tutufan <at> gmail.com>

Date: Thu, 26 Mar 2009 16:00:03 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Mike Coleman <tutufan <at> gmail.com>
Cc: 2790 <at> debbugs.gnu.org
Subject: bug#2790: emacs 22.1.1 cannot open 5GB file on 64GB 64-bit GNU/Linux box
Date: Fri, 27 Mar 2009 22:12:54 -0400
> Okay, tried it (emacs-23.0.91), but no luck.  Looks very nice, but
> finding that large file produced the same error.  The value of
> 'most-positive-fixnum' prints correctly, though (which is different).

There was an incorrect check that limited the size to INT_MAX/4
(i.e. 512MB for systems where ints are 32bit).  I've removed this check
in the CVS code (see patch below).  I am now able to open an 800MB file
with this check removed.  OTOH with a 2GB file, I got some unjustified
"memory exhausted" error, but I haven't tracked it down yet.  Note also
that when you open large files, it's worthwhile to use
find-file-literally to be sure it's opened in unibyte mode; otherwise
it gets decoded which takes ages.  Also if the file has many lines (my
800MB file was made up by copying a C file many times, so it had
millions of lines), turning off line-number-mode is is needed to recover
responsiveness when navigating near the end of the buffer.


        Stefan


Index: src/fileio.c
===================================================================
RCS file: /sources/emacs/emacs/src/fileio.c,v
retrieving revision 1.651
retrieving revision 1.652
diff -u -r1.651 -r1.652
--- src/fileio.c	24 Mar 2009 14:14:54 -0000	1.651
+++ src/fileio.c	28 Mar 2009 02:06:08 -0000	1.652
@@ -3300,7 +3300,11 @@
 	     overflow.  The calculations below double the file size
 	     twice, so check that it can be multiplied by 4 safely.  */
 	  if (XINT (end) != st.st_size
-	      || st.st_size > INT_MAX / 4)
+	      /* Actually, it should test either INT_MAX or LONG_MAX
+		 depending on which one is used for EMACS_INT.  But in
+		 any case, in practice, this test is redundant with the
+		 one above.
+		 || st.st_size > INT_MAX / 4 */)
 	    error ("Maximum buffer size exceeded");
 
 	  /* The file size returned from stat may be zero, but data




This bug report was last modified 13 years and 315 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.