www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2242] New: linux system calls are canceled by GC

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2242

           Summary: linux system calls are canceled by GC
           Product: D
           Version: 2.014
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: gide nwawudu.com


http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.bugs&article_id=14685

 On Tue, 22 Jul 2008 09:50:06 -0400, shinichiro.h wrote:

Hi D guys, The following program import std.stream; import std.cstream; import std.thread; class ReaderThread : Thread { override int run() { char[] line = din.readLine(); dout.writeLine(line); return 0; } } void main() { ReaderThread rt = new ReaderThread(); rt.start(); for (int i = 0; i < 100000; i++) { new Object; } rt.wait(); } works as intended on Windows (suppose a scenario in which a user may input a line after the for-loop): 1. Start ReaderThread 2. 100000 allocations 3. a user input a line 4. show the line and finish ReaderThread 5. the program finishes but doesn't work on Linux 1. Start ReaderThread 2. 100000 allocations 3. during the allocations, GC is invoked and SIGUSR1 is issued to stop the world 4. the SIGUSR1 makes read system call fail (errno=EINTR) 5. the program outputs empty line and finishes without waiting the user's input. this issue is serious when we are writing network applications (synchronous accept(2) or read(2) fail often). The following super short patch will fix the problem: --- /usr/local/dmd/src/phobos/std/thread.d 2008-04-28 06:00:52.000000000 +0900 +++ thread.d 2008-07-22 03:21:11.000000000 +0900 -1044,6 +1044,7 if (result) goto Lfail; sigact.sa_handler = &pauseHandler; + sigact.sa_flags = 0x10000000u /* SA_RESTART */; result = sigaction(SIGUSR1, &sigact, null); if (result) goto Lfail; you may want to put SA_RESTART in somewhere else (supposedly, std.c.linux.linux?) though. I believe tango doesn't have this problem since its Thread.d seems to set SA_RESTART. I hope this patch is accepted in near future. I'm using dmd-2.014. --
Jul 24 2008
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2242


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Comment #1 from bugzilla digitalmars.com  2008-08-14 03:01 -------
Fixed dmd 1.034 and 2.018


-- 
Aug 14 2008