Bug 11040 – Exception from writeln function if the input size is big

Status
RESOLVED
Resolution
WORKSFORME
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2013-09-14T14:18:00Z
Last change time
2017-01-10T23:44:11Z
Assigned to
nobody
Creator
kerdemdemir

Comments

Comment #0 by kerdemdemir — 2013-09-14T14:18:37Z
Short summary of the problem can be seen in link : http://stackoverflow.com/questions/18805224/exception-from-writeln-function-if-the-input-size-is-big/18805619?noredirect=1#18805619 In the code below when float[] amplitudeByTime is more than 1660 I am getting a exception from writeln function. If the size of this array less than 1660(which I can determine with global variable"static const int total_data_size") no exception occurs. Exception : std.stdio.StdioException@std\stdio.d(2431): Bad file descriptor ---------------- 0x0040EA7B 0x00411F62 0x0040FD80 0x0040FDBB 0x0040F9B9 0x0040B774 0x75EDD2E9 in BaseThreadInitThunk 0x77BF1603 in RtlInitializeExceptionChain 0x77BF15D6 in RtlInitializeExceptionChain ---------------- main.d : import std.stdio; import std.numeric; import std.file; import std.algorithm; import std.array; import std.conv; import std.string; static const int total_data_size = 1661 ;//131072; //2^16 static const int sampling_frequency = 44100; auto file2string(string filepath) { char[] buf; // line; int line_counter = 0; string input; try { input = cast(string)std.file.read(filepath); } catch (Exception e) { writeln(e); } int count = 0; foreach (line; input.splitter("\n")) { line = chomp(line); if (isNumeric(line)) { count++; if (count == total_data_size) { buf ~= line; break; } buf ~= (line ~ " "); } } return to!(float[])(split(buf)); } void main() { char[] buff; auto amplitudeByTime = file2string("C:/Users/USER/expTreeTry/spectogram/src/sample-data8.txt"); writeln(amplitudeByTime); char[] read; readln(read); }
Comment #1 by mk — 2017-01-10T23:44:11Z
No sample data provided, can't reproduce.