www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11492] New: Executable with thread termination crashes (worked in 2.63, works on Windows)

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

           Summary: Executable with thread termination crashes (worked in
                    2.63, works on Windows)
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: atila.neves gmail.com



---
This is on dmd 2.64.2 on Arch Linux 64-bit. Works on Windows, used to work in
2.63. Code to reproduce:

import std.concurrency;

private void threadWriter() {
    for(bool running = true; running;) {
        receive(
            (Tid i) {
            },
            (OwnerTerminated trm) {
                running = false;
            }
        );
    }
}

void main() {
    spawn(&threadWriter);
}

dmd thead.d
./thread.d
zsh: segmentation fault (core dumped) ./thread

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 10 2013
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11492


Martin Krejcirik <mk krej.cz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mk krej.cz



This has been fixed recently (see bug 11309 and bug 11378). Are you sure you
are running the latest version ? If so, mark as regression.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 10 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11492




---

 This has been fixed recently (see bug 11309 and bug 11378). Are you sure you
 are running the latest version ? If so, mark as regression.
There are no newer packages for Arch. To make sure, I downloaded the zip with dmd 2.064.2 from dlang.org just now, used it to compile the sample program for this bug and the resulting binary crashed. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 11 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11492


Martin Krejcirik <mk krej.cz> changed:

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



It seems to crash in dpaste too.

*** This issue has been marked as a duplicate of issue 11309 ***

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 11 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11492




Actually this bug may no be a dup of 11309, as that bug did not segfault, I
confused it with another ralated issue, but I'm sure Martin Nowak will sort it
out ;-)

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 11 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11492


Atila Neves <atila.neves gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|DUPLICATE                   |



---
This example from TDPL (the only difference is the std.exception import for
enforce) also results in a binary that crashes when compiling with dmd 2.064.2:

import std.concurrency, std.stdio, std.exception;

void main() {
    auto low = 0, high = 100;
    auto tid = spawn(&fun, low, high);
    foreach(i; low .. high) {
        writeln("Main thread: ", i);
        tid.send(thisTid, i);
        enforce(receiveOnly!Tid() == tid);
    }
}

void fun(int low, int high) {
    for(;;) {
        auto msg = receiveOnly!(Tid, int)();
        writeln("Secondary thread: ", msg[1]);
        msg[0].send(thisTid);
    }
}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 12 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11492


Martin Nowak <code dawg.eu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code dawg.eu



Both examples work correctly for me.
In the latter there is an unhandled exception.
std.concurrency.OwnerTerminated std/concurrency.d(234): Owner terminated

I tried 2.064.2 and master with all 32/64 compiler combinations.

It seems like threads don't work on dpaste.
http://dpaste.dzfl.pl/d6f2fedb (tried dmd 2.064.2, dmd git, ldc 0.12.0).

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 12 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11492




Can you find out the function where the segfault happens?

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 12 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11492




---

 Both examples work correctly for me.
 In the latter there is an unhandled exception.
 std.concurrency.OwnerTerminated std/concurrency.d(234): Owner terminated
I get that unhandled exception in 2.063. On 2.064 it crashes. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 13 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11492




---

 Can you find out the function where the segfault happens?
In the last example (the one from TDPL) I don't get a segfault, I get SIGILL: /lib64/ld-linux-x86-64.so.2 std.variant.__T8VariantNVm32Z.VariantN.__T10convertsToTS3std8typecons35__T5TupleTS3std11concurrency3TidTiZ5TupleZ.convertsTo() ( this=<error reading variable: Could not find the frame base for "std.variant.__T8VariantNVm32Z.VariantN.__T10convertsToTS3std8typecons35__T5TupleTS3std11concurrency3TidTiZ5TupleZ.convertsTo()".>) at /usr/include/dlang/dmd/std/variant.d:633 std.concurrency.Message.__T10convertsToTS3std11concurrency3TidTiZ.convertsTo() ( this=<error reading variable: Could not find the frame base for "std.concurrency.Message.__T10convertsToTS3std11concurrency3TidTiZ.convertsTo()".>) at /usr/include/dlang/dmd/std/concurrency.d:125 std.concurrency.MessageBox.__T3getTDFNbNfS3std11concurrency3TidiZvTPFNaNfC3std11concurrency14LinkTerminatedZvTPFNaNfC3std11concurrency15OwnerTerminatedZvTPFS3std7variant17__T8VariantNVm32Z8VariantNZvZ.get() ( this=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTDFNbNfS3std11concurrency3TidiZvTPFNaNfC3std11concurrency14LinkTerminatedZvTPFNaNfC3std11concurrency15OwnerTerminatedZvTPFS3std7variant17__T8VariantNVm32Z8V riantNZvZ.get()".>, msg=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTDFNbNfS3std11concurrency3TidiZvTPFNaNfC3std11concurrency14LinkTerminatedZvTPFNaNfC3std11concurrency15OwnerTerminatedZvTPFS3std7variant17__T8VariantNVm32Z8VariantNZvZ.get()".>) at /usr/include/dlang/dmd/std/concurrency.d:1150 std.concurrency.MessageBox.__T3getTDFNbNfS3std11concurrency3TidiZvTPFNaNfC3std11concurrency14LinkTerminatedZvTPFNaNfC3std11concurrency15OwnerTerminatedZvTPFS3std7variant17__T8VariantNVm32Z8VariantNZvZ.get() ( this=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTDFNbNfS3std11concurrency3TidiZvTPFNaNfC3std11concurrency14LinkTerminatedZvTPFNaNfC3std11concurrency15OwnerTerminatedZvTPFS3std7variant17__T8VariantNVm32Z8V riantNZvZ.get()".>, list=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTDFNbNfS3std11concurrency3TidiZvTPFNaNfC3std11concurrency14LinkTerminatedZvTPFNaNfC3std11concurrency15OwnerTerminatedZvTPFS3std7variant17__T8VariantNVm32Z8VariantNZvZ.get()".>) at /usr/include/dlang/dmd/std/concurrency.d:1238 std.concurrency.MessageBox.__T3getTDFNbNfS3std11concurrency3TidiZvTPFNaNfC3std11concurrency14LinkTerminatedZvTPFNaNfC3std11concurrency15OwnerTerminatedZvTPFS3std7variant17__T8VariantNVm32Z8VariantNZvZ.get() ( this=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTDFNbNfS3std11concurrency3TidiZvTPFNaNfC3std11concurrency14LinkTerminatedZvTPFNaNfC3std11concurrency15OwnerTerminatedZvTPFS3std7variant17__T8VariantNVm32Z8V riantNZvZ.get()".>, _param_3=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTDFNbNfS3std11concurrency3TidiZvTPFNaNfC3std11concurrency14LinkTerminatedZvTPFNaNfC3std11concurrency15OwnerTerminatedZvTPFS3std7variant17__T8VariantNVm32Z8V riantNZvZ.get()".>, _param_2=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTDFNbNfS3std11concurrency3TidiZvTPFNaNfC3std11concurrency14LinkTerminatedZvTPFNaNfC3std11concurrency15OwnerTerminatedZvTPFS3std7variant17__T8VariantNVm32Z8V riantNZvZ.get()".>, _param_1=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTDFNbNfS3std11concurrency3TidiZvTPFNaNfC3std11concurrency14LinkTerminatedZvTPFNaNfC3std11concurrency15OwnerTerminatedZvTPFS3std7variant17__T8VariantNVm32Z8V riantNZvZ.get()".>, _param_0=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTDFNbNfS3std11concurrency3TidiZvTPFNaNfC3std11concurrency14LinkTerminatedZvTPFNaNfC3std11concurrency15OwnerTerminatedZvTPFS3std7variant17__T8VariantNVm32Z8VariantNZvZ.get()".>) at /usr/include/dlang/dmd/std/concurrency.d:1314 std.concurrency.__T11receiveOnlyTS3std11concurrency3TidTiZ.receiveOnly() ( __HID10=<error reading variable: Could not find the frame base for "std.concurrency.__T11receiveOnlyTS3std11concurrency3TidTiZ.receiveOnly()".>) at /usr/include/dlang/dmd/std/concurrency.d:718 Could not find the frame base for "concurrency_tdpl.fun()".>, low=<error reading variable: Could not find the frame base for "concurrency_tdpl.fun()".>) at concurrency_tdpl.d:15 (this=<error reading variable: Could not find the frame base for "std.concurrency.__T6_spawnTPFiiZvTiTiZ._spawn()".>) at /usr/include/dlang/dmd/std/concurrency.d:487 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 13 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11492




PST ---

 Can you find out the function where the segfault happens?
In the original example: Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7ffff7308700 (LWP 5006)] 0x0000000000471b83 in std.variant.__T8VariantNVm32Z.VariantN.__T7handlerTC3std11concurrency15OwnerTerminatedZ.handler() ( parm=<error reading variable: Could not find the frame base for "std.variant.__T8VariantNVm32Z.VariantN.__T7handlerTC3std11concurrency15OwnerTermi atedZ.handler()".>, pStore=<error reading variable: Could not find the frame base for "std.variant.__T8VariantNVm32Z.VariantN.__T7handlerTC3std11concurrency15OwnerTermi atedZ.handler()".>, selector=<error reading variable: Could not find the frame base for "std.variant.__T8VariantNVm32Z.VariantN.__T7handlerTC3std11concurrency15OwnerTerminatedZ.handler()".>) at /usr/include/dlang/dmd/std/variant.d:294 294 switch (selector) (gdb) bt std.variant.__T8VariantNVm32Z.VariantN.__T7handlerTC3std11concurrency15OwnerTerminatedZ.handler() ( parm=<error reading variable: Could not find the frame base for "std.variant.__T8VariantNVm32Z.VariantN.__T7handlerTC3std11concurrency15OwnerTermi atedZ.handler()".>, pStore=<error reading variable: Could not find the frame base for "std.variant.__T8VariantNVm32Z.VariantN.__T7handlerTC3std11concurrency15OwnerTermi atedZ.handler()".>, selector=<error reading variable: Could not find the frame base for "std.variant.__T8VariantNVm32Z.VariantN.__T7handlerTC3std11concurrency15OwnerTerminatedZ.handler()".>) at /usr/include/dlang/dmd/std/variant.d:294 std.variant.__T8VariantNVm32Z.VariantN.__T10convertsToTS3std11concurrency3TidZ.convertsTo() ( this=<error reading variable: Could not find the frame base for "std.variant.__T8VariantNVm32Z.VariantN.__T10convertsToTS3std11concurrency3TidZ.convertsTo()".>) at /usr/include/dlang/dmd/std/variant.d:633 std.concurrency.Message.__T10convertsToTS3std11concurrency3TidZ.convertsTo() ( this=<error reading variable: Could not find the frame base for "std.concurrency.Message.__T10convertsToTS3std11concurrency3TidZ.convertsTo()".>) at /usr/include/dlang/dmd/std/concurrency.d:123 std.concurrency.MessageBox.__T3getTPFNaNbNfS3std11concurrency3TidZvTDFNbNfC3std11concurrency15OwnerTerminatedZvZ.get() ( this=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTPFNaNbNfS3std11concurrency3TidZvTDFNbNfC3std11concurrency15OwnerTer inatedZvZ.get()".>, msg=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTPFNaNbNfS3std11concurrency3TidZvTDFNbNfC3std11concurrency15OwnerTerminatedZvZ.get()".>) at /usr/include/dlang/dmd/std/concurrency.d:1150 std.concurrency.MessageBox.__T3getTPFNaNbNfS3std11concurrency3TidZvTDFNbNfC3std11concurrency15OwnerTerminatedZvZ.get() ( this=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTPFNaNbNfS3std11concurrency3TidZvTDFNbNfC3std11concurrency15OwnerTer inatedZvZ.get()".>, msg=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTPFNaNbNfS3std11concurrency3TidZvTDFNbNfC3std11concurrency15OwnerTerminatedZvZ.get()".>) at /usr/include/dlang/dmd/std/concurrency.d:1189 std.concurrency.MessageBox.__T3getTPFNaNbNfS3std11concurrency3TidZvTDFNbNfC3std11concurrency15OwnerTerminatedZvZ.get() ( this=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTPFNaNbNfS3std11concurrency3TidZvTDFNbNfC3std11concurrency15OwnerTer inatedZvZ.get()".>, msg=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTPFNaNbNfS3std11concurrency3TidZvTDFNbNfC3std11concurrency15OwnerTerminatedZvZ.get()".>) at /usr/include/dlang/dmd/std/concurrency.d:1201 std.concurrency.MessageBox.__T3getTPFNaNbNfS3std11concurrency3TidZvTDFNbNfC3std11concurrency15OwnerTerminatedZvZ.get() ( this=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTPFNaNbNfS3std11concurrency3TidZvTDFNbNfC3std11concurrency15OwnerTer inatedZvZ.get()".>, list=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTPFNaNbNfS3std11concurrency3TidZvTDFNbNfC3std11concurrency15OwnerTerminatedZvZ.get()".>) at /usr/include/dlang/dmd/std/concurrency.d:1217 std.concurrency.MessageBox.__T3getTPFNaNbNfS3std11concurrency3TidZvTDFNbNfC3std11concurrency15OwnerTerminatedZvZ.get() ( this=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTPFNaNbNfS3std11concurrency3TidZvTDFNbNfC3std11concurrency15OwnerTer inatedZvZ.get()".>, _param_1=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTPFNaNbNfS3std11concurrency3TidZvTDFNbNfC3std11concurrency15OwnerTer inatedZvZ.get()".>, _param_0=<error reading variable: Could not find the frame base for "std.concurrency.MessageBox.__T3getTPFNaNbNfS3std11concurrency3TidZvTDFNbNfC3std11concurrency15OwnerTerminatedZvZ.get()".>) at /usr/include/dlang/dmd/std/concurrency.d:1314 std.concurrency.__T7receiveTPFNaNbNfS3std11concurrency3TidZvTDFNbNfC3std11concurrency15OwnerTerminatedZvZ.receive() ( _param_1=<error reading variable: Could not find the frame base for "std.concurrency.__T7receiveTPFNaNbNfS3std11concurrency3TidZvTDFNbNfC3std11concurrency15OwnerTermina edZvZ.receive()".>, _param_0=<error reading variable: Could not find the frame base for "std.concurrency.__T7receiveTPFNaNbNfS3std11concurrency3TidZvTDFNbNfC3std11concurrency15OwnerTerminatedZvZ.receive()".>) at /usr/include/dlang/dmd/std/concurrency.d:635 thread_local_singleton.d:8 (this=<error reading variable: Could not find the frame base for "std.concurrency.__T6_spawnTPFZvZ._spawn()".>) at /usr/include/dlang/dmd/std/concurrency.d:487 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 13 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11492




Apparently it crashes in the Variant code when it tests for conversion.
Can you try the following small program with your setup?

cat > bug.d << CODE
import std.concurrency, std.variant, std.stdio;

void main()
{
    Variant v;
    v = new OwnerTerminated(thisTid);
    if (v.convertsTo!Tid())
        writeln("does convert");
    else
        writeln("doesn't convert");
}
CODE

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 13 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11492




PST ---

 Apparently it crashes in the Variant code when it tests for conversion.
 Can you try the following small program with your setup?
 
 cat > bug.d << CODE
 import std.concurrency, std.variant, std.stdio;
 
 void main()
 {
     Variant v;
     v = new OwnerTerminated(thisTid);
     if (v.convertsTo!Tid())
         writeln("does convert");
     else
         writeln("doesn't convert");
 }
 CODE
It crashes on the convertsTo line. I copied std.variant into my own copy and inserted writelns since I couldn't get gdb to tell me where it crashed. convertsTo seems to have all its local variables in order then promptly crashes when it calls fptr in line 633. It makes it through to handler!(A) up to line 294 then crashes on the switch. Again, no help from the debugger. I printed the value of selector just before the switch statement and it contains, as expected, OpID.testConversion. I also added a writeln after every case, including default, and none of them are printed. I tried single-stepping but it just seems to crash on the switch. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 13 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11492




Looks much like a duplicate of bug 11406.
Can you check whether ld.bfd works for you?

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 13 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11492




PST ---

 Looks much like a duplicate of bug 11406.
 Can you check whether ld.bfd works for you?
Sigh... I actually considered this once while at work then forgot about it. ld.bfd works. I agree this is a duplicate, it's just that it manifests in a lot worse way with std.concurrency. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 14 2013
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11492


Atila Neves <atila.neves gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |DUPLICATE



PST ---
*** This issue has been marked as a duplicate of issue 11406 ***

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 14 2013