From: Xavier Leroy <xavier.leroy@inria.fr>
To: Garry Hodgson <garry@sage.att.com>
Cc: ocaml <caml-list@inria.fr>
Subject: Re: [Caml-list] error opening large file
Date: Tue, 15 Jan 2002 10:56:12 +0100 [thread overview]
Message-ID: <20020115105612.A4497@pauillac.inria.fr> (raw)
In-Reply-To: <3C3F52ED.2F4B0190@sage.att.com>; from garry@sage.att.com on Fri, Jan 11, 2002 at 04:02:37PM -0500
> i get the following error when i open a large file (2561435180 bytes):
>
> let chan = open_in( "com.zone" );;
> Uncaught exception:
> Sys_error
> "com.zone: Value too large for defined data type".
>
> is there a 2G file size limitation? if so, why?
> i found the same bug in erlang, though C is ok with it.
Actually, this limitation is in the kernel and C library. To ensure
backward compatibility with old programs that assume that the size of
a file fits in a 32-bit signed integer, system calls come in two
versions and/or with special options, one to select 32-bit file sizes
(and fail on files larger than 2G), one to select 64-bit file sizes.
The choice between the two versions is done through compile-time
defines, and the default can be either 32 or 64 depending on the C library.
You could try to recompile the OCaml sources with the -D_FILE_OFFSET_BITS=64
flag. That will let you open the large file, and read it sequentially,
but of course file positions and stats (as returned by
in_channel_length, seek_in, Unix.stat, etc) will be wrong, since they
wrap around at 2^30 on a 32-bit machine.
Now that I think I've figured it out, I plan to compile future
versions of OCaml in 64-bit-file-size mode, and add new library functions
to manipulate file positions and sizes as 64-bit integers (seek_in64,
Unix.stat64, etc).
- Xavier Leroy
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
next prev parent reply other threads:[~2002-01-15 9:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-11 21:02 Garry Hodgson
2002-01-11 21:51 ` Olivier Andrieu
2002-01-15 9:56 ` Xavier Leroy [this message]
2002-01-16 8:53 ` Florian Douetteau
2002-01-23 15:49 ` Xavier Leroy
2002-01-11 23:32 Florian Douetteau
2002-01-12 0:02 ` David Monniaux
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020115105612.A4497@pauillac.inria.fr \
--to=xavier.leroy@inria.fr \
--cc=caml-list@inria.fr \
--cc=garry@sage.att.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox