Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large buffers #3262

Closed
vicuna opened this issue Mar 15, 2002 · 1 comment
Closed

Large buffers #3262

vicuna opened this issue Mar 15, 2002 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Mar 15, 2002

Original bug ID: 1015
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Gerd Stolpmann
Version: 3.04 + current CVS version
OS: Linux
Submission from: p50816611.dip0.t-ipconnect.de (80.129.102.17)

Hello,

I have recently tested whether large buffers near the limit of
Sys.max_string_length
work. They don't:

let b = Buffer.create 1;;

val b : Buffer.t =

Buffer.add_string b (String.make Sys.max_string_length ' ');;

Exception: Invalid_argument "String.create".

This can be easily fixed by adding a line to the function Buffer.resize:

let resize b more =
let len = b.length in
let new_len = ref len in
while b.position + more > !new_len do new_len := 2 * !new_len done;

(* NEW: *)
if !new_len > Sys.max_string_length && b.position + more <=
Sys.max_string_length
then new_len := Sys.max_string_length;

let new_buffer = String.create !new_len in
String.blit b.buffer 0 new_buffer 0 b.position;
b.buffer <- new_buffer;
b.length <- !new_len

I think it is worth doing this fix because the 16MB limit for 32 bit processors
is sometimes problematic, and it should be at least ensured that one can
exhaust the 16MB space.

The new Lexing code (thank you for adding it) has the problem, too.

Gerd

@vicuna
Copy link
Author

vicuna commented Mar 29, 2002

Comment author: administrator

Fixed 2002-03-29 by XL

@vicuna vicuna closed this as completed Mar 29, 2002
@vicuna vicuna added the bug label Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant