You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: