Jump to page: 1 2
Thread overview
[Issue 11309] New: std.concurrency: OwnerTerminated message doesn't work
Oct 21, 2013
Martin Krejcirik
Oct 22, 2013
Walter Bright
Oct 22, 2013
Andrej Mitrovic
Oct 22, 2013
Martin Krejcirik
Oct 23, 2013
Martin Krejcirik
Oct 25, 2013
Martin Nowak
Oct 26, 2013
Walter Bright
Oct 29, 2013
Martin Nowak
Oct 29, 2013
Martin Nowak
Oct 30, 2013
Walter Bright
October 21, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11309

           Summary: std.concurrency: OwnerTerminated message doesn't work
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: mk@krej.cz


--- Comment #0 from Martin Krejcirik <mk@krej.cz> 2013-10-21 03:44:09 CEST ---
Not sure where is the problem, but the thread doesn't end as expected.

------
import core.thread, std.concurrency, std.stdio;

void main()
{
    writeln("starting");
    auto tid = spawn(&worker);
    Thread.sleep(dur!"msecs"(100));
    tid.send(10);
    Thread.sleep(dur!"msecs"(100));
    writeln("finishing");
}

void worker()
{
    for (bool running = true; running; )
    {
        receive(
            (int m) { writeln("Got ", m); },
            (OwnerTerminated unused) { writeln("main ended"); running = false;
}
        );
    }
}
-----

DMD32 D Compiler v2.064-devel-9e9a329
Linux 32.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 22, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11309


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2013-10-22 14:26:29 PDT ---
Did this work on earlier versions of dmd?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 22, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11309


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich@gmail.com


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-10-22 14:29:29 PDT ---
It works in 2.063.2, but gets stuck in git-head. I'm on Win7 x86.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 22, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11309



--- Comment #3 from Martin Krejcirik <mk@krej.cz> 2013-10-23 01:31:28 CEST ---
If it's any help, try adding the folowing terminate() function and call it at
the end of main(). The thread will end correctly (but the main segfaults). I
was using it like this in 2.063 and it worked. I guess something has changed in
druntime.

extern (C)
{
    // These are for control of termination
    void rt_moduleTlsDtor();
    void thread_joinAll();
    void rt_moduleDtor();
    void gc_term();
    void _STD_critical_term();
    void _STD_monitor_staticdtor();
} /* end extern C */

void terminate()
{
    // Phobos termination (since we can't really make main() return):
    rt_moduleTlsDtor();
    thread_joinAll();
    rt_moduleDtor();
    gc_term();
    version (Posix)
    {
        _STD_critical_term();
        _STD_monitor_staticdtor();
    }

    exit(EXIT_SUCCESS);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 23, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11309



--- Comment #4 from Martin Krejcirik <mk@krej.cz> 2013-10-23 15:33:31 CEST ---
This seems to be the offender:

https://github.com/D-Programming-Language/druntime/commit/db772968244bf5af37a81060758a1f266e0b698f

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 25, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11309


Martin Nowak <code@dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code@dawg.eu
         AssignedTo|nobody@puremagic.com        |code@dawg.eu


--- Comment #5 from Martin Nowak <code@dawg.eu> 2013-10-25 08:39:34 PDT ---
This happens because the OwnerTerminated mechanism is sensible to the order in
which threads are joined.
The regression was introduced with
https://github.com/D-Programming-Language/druntime/pull/600.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 26, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11309



--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2013-10-26 13:27:47 PDT ---
What's the solution here? Revert the pull?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 29, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11309



--- Comment #7 from Martin Nowak <code@dawg.eu> 2013-10-29 07:27:31 PDT ---
(In reply to comment #6)
> What's the solution here? Revert the pull?

Refixing bug 10976 which was caused by bug 11378.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 29, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11309



--- Comment #8 from Martin Nowak <code@dawg.eu> 2013-10-29 12:04:58 PDT ---
We're taking on a new liability of the runtime here. AFAIK the following
behavior isn't documented anywhere.
Threads are joined in the same order they were created (slightly less strict,
parent threads are joined before their child threads). An argumentation for
this is that a child thread is an owned resource of the parent thread so the
parent thread must have the chance to join or terminate this resource in it's
thread dtor.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 30, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11309



--- Comment #9 from github-bugzilla@puremagic.com 2013-10-30 00:13:17 PDT ---
Commit pushed to master at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/b73e2c4554db5bb67ceb51adb053e715b2a090b5 fix Issue 11309 - std.concurrency: OwnerTerminated message doesn't work

- add regression test
- Revert "fix Issue 10976 - thread_joinAll after main exit performed too late"

This reverts commit 7d82a57c82f9a5359468680f36aa1026243e6f9e.

Conflicts:
    src/core/runtime.d
    src/rt/dmain2.d

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2