digitalmars.D - GC Bug? Error: Unable to accept socket connection: Interrupted system call
- Huang Guan (25/25) Jun 07 2008 I got this error under Linux while I didn't find it under Windows.
- Sean Kelly (7/16) Jun 07 2008 Are you saying the thread never completes? I might expect s.accept()
- Huang Guan (3/22) Jun 08 2008 Yes, Tango doesn't have this problem and I am using it now.
- Frank Benoit (8/32) Jun 08 2008 Stdout is not synchronized.
- Sean Kelly (9/31) Jun 08 2008 strange error such as exited without any warning.
I got this error under Linux while I didn't find it under Windows. This is the code: private import std.thread, std.stdio, std.gc, std.c.time, std.socket; Socket s; int test(void* arg){ s.bind( new InternetAddress( 8888 ) ); s.listen(10); Socket a = s.accept(); // never reach return 0; } int main() { s = new TcpSocket(); Thread th = new Thread( &test, null, 0 ); th.start(); sleep(1); std.gc.genCollect(); //raise error. return 0; } Obviously this problem occurred in std.gc.genCollect( or std.gc.fullCollect ). I am writing a server program and I met this problem and I am very sad now!! My server runs under Windows well on some machines but it always raises errors under Linux unless I disable gc!!! Became a little hate phobos :-( Help me please!!
Jun 07 2008
== Quote from Huang Guan (gdxxhg gmail.com)'s articleI got this error under Linux while I didn't find it under Windows. This is the code: private import std.thread, std.stdio, std.gc, std.c.time, std.socket; Socket s; int test(void* arg){ s.bind( new InternetAddress( 8888 ) ); s.listen(10); Socket a = s.accept(); // never reachAre you saying the thread never completes? I might expect s.accept() to return prematurely if a GC cycle occurs, but I wouldn't expect it to lock up. But then I've never looked at std.socket, so perhaps there's a bug in the code. I can assure you that Tango doesn't have this problem :p Sean
Jun 07 2008
Sean Kelly Wrote:== Quote from Huang Guan (gdxxhg gmail.com)'s articleYes, Tango doesn't have this problem and I am using it now. I found there is a bug in class Stdout( Tango ). Once Stdout accessed by many threads, it raised some strange error such as exited without any warning.I got this error under Linux while I didn't find it under Windows. This is the code: private import std.thread, std.stdio, std.gc, std.c.time, std.socket; Socket s; int test(void* arg){ s.bind( new InternetAddress( 8888 ) ); s.listen(10); Socket a = s.accept(); // never reachAre you saying the thread never completes? I might expect s.accept() to return prematurely if a GC cycle occurs, but I wouldn't expect it to lock up. But then I've never looked at std.socket, so perhaps there's a bug in the code. I can assure you that Tango doesn't have this problem :p Sean
Jun 08 2008
Huang Guan schrieb:Sean Kelly Wrote:Stdout is not synchronized. Since nomally you do not want to mix the output of multiple threads, this is ok. If you want to do "printf debugging" from many threads, use the synchronized Trace. import tango.util.log.Trace; Trace.formatln( .... );== Quote from Huang Guan (gdxxhg gmail.com)'s articleYes, Tango doesn't have this problem and I am using it now. I found there is a bug in class Stdout( Tango ). Once Stdout accessed by many threads, it raised some strange error such as exited without any warning.I got this error under Linux while I didn't find it under Windows. This is the code: private import std.thread, std.stdio, std.gc, std.c.time, std.socket; Socket s; int test(void* arg){ s.bind( new InternetAddress( 8888 ) ); s.listen(10); Socket a = s.accept(); // never reachAre you saying the thread never completes? I might expect s.accept() to return prematurely if a GC cycle occurs, but I wouldn't expect it to lock up. But then I've never looked at std.socket, so perhaps there's a bug in the code. I can assure you that Tango doesn't have this problem :p Sean
Jun 08 2008
== Quote from Huang Guan (gdxxhg gmail.com)'s articleSean Kelly Wrote:strange error such as exited without any warning. Stdout is not thread-safe. This is intentional, as adding thread safety incurs a performance cost that the user may not want. If you must write to Stdout from multiple threads, I suggest either looking at the logging facilities (which are thread-safe), or synchronizing in some other way, this being the simplest: synchroized(Stdout) Stdout( "blah" ); Sean== Quote from Huang Guan (gdxxhg gmail.com)'s articleYes, Tango doesn't have this problem and I am using it now. I found there is a bug in class Stdout( Tango ). Once Stdout accessed by many threads, it raised someI got this error under Linux while I didn't find it under Windows. This is the code: private import std.thread, std.stdio, std.gc, std.c.time, std.socket; Socket s; int test(void* arg){ s.bind( new InternetAddress( 8888 ) ); s.listen(10); Socket a = s.accept(); // never reachAre you saying the thread never completes? I might expect s.accept() to return prematurely if a GC cycle occurs, but I wouldn't expect it to lock up. But then I've never looked at std.socket, so perhaps there's a bug in the code. I can assure you that Tango doesn't have this problem :p Sean
Jun 08 2008