digitalmars.D.learn - why spawn crash?
- mzfhhhh (24/25) Jan 22 2015 i wrote a test code:
- Steven Schveighoffer (4/28) Jan 23 2015 That sounds like a bug in stdio. fwide is the horrible attempt of C
i wrote a test code: void worker(int firstNumber) { Thread.sleep(1.msecs); } void main() { foreach (i; 1 .. 1000) { spawn(&worker, i ); writeln(i); } thread_joinAll(); writeln("ok"); } sometimes it's ok,sometimes it's crashed ! why ? here is one of times callstack message: test.exe!_free() test.exe!_fwide() test.exe!_fwide() test.exe!__ReleaseSemaphore() test.exe!_fwide()test.exe!main __modctor() 行 3test.exe!rt minfo __T14runModuleFuncsS482rt5minfo11ModuleGroup11runTlsCtorsMFZ9__lambda1Z runModuleFuncs() test.exe!___threadstartex 4()
Jan 22 2015
On 1/22/15 10:20 PM, mzfhhhh wrote:i wrote a test code: void worker(int firstNumber) { Thread.sleep(1.msecs); } void main() { foreach (i; 1 .. 1000) { spawn(&worker, i ); writeln(i); } thread_joinAll(); writeln("ok"); } sometimes it's ok,sometimes it's crashed ! why ? here is one of times callstack message: test.exe!_free() test.exe!_fwide() test.exe!_fwide() test.exe!__ReleaseSemaphore() test.exe!_fwide()That sounds like a bug in stdio. fwide is the horrible attempt of C stdio to do wide character output. -Stevetest.exe!main __modctor() 行 3test.exe!rt minfo __T14runModuleFuncsS482rt5minfo11ModuleGroup11runTlsCtorsMFZ9__lambda1Z runModuleFuncs() test.exe!___threadstartex 4()
Jan 23 2015
thanks,you are right. window console show chinese char is not right, so i try to add this code: " extern(C) int setlocale(int, char*); static this() { fwide(core.stdc.stdio.stdout, 1); setlocale(LC_CTYPE, cast(char*)"china"); } " it's looks like solve the problem,but caused another problem. now i use "chcp 65001" command to change the code page and change the font to "lucida console".it works correctly!
Jan 23 2015
On Saturday, 24 January 2015 at 01:54:32 UTC, mzfhhhh wrote:thanks,you are right. window console show chinese char is not right, so i try to add this code: " extern(C) int setlocale(int, char*); static this() { fwide(core.stdc.stdio.stdout, 1); setlocale(LC_CTYPE, cast(char*)"china"); } " it's looks like solve the problem,but caused another problem. now i use "chcp 65001" command to change the code page and change the font to "lucida console".it works correctly!this way also have problem! look this bug report: Issue 13651 - Writing Unicode text with console code page 65001 (UTF-8) may fail now,i use this code show string on window console: void write(string s) { import std.windows.charset:toMBSz; printf(toMBSz(s)); } void writeln(string s) { write(s); printf("\r\n"); }
Feb 08 2015