September 14, 2013 [Issue 11040] New: Exception from writeln function if the input size is big | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=11040 Summary: Exception from writeln function if the input size is big Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Severity: critical Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: kerdemdemir@hotmail.com --- Comment #0 from kerdemdemir <kerdemdemir@hotmail.com> 2013-09-14 14:18:37 PDT --- 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); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation