www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19265] New: Multiple calls to rt_init/rt_term leads to SIGILL

https://issues.dlang.org/show_bug.cgi?id=19265

          Issue ID: 19265
           Summary: Multiple calls to rt_init/rt_term leads to SIGILL in
                    _d_initMonoTime
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: chalucha gmail.com

I'm playing with fork() with druntime initialized after the fork, but I found
that I can't call rt_init/rt_term to cleanup the runtime multiple times.

Simple test case:

extern extern(C) int _d_run_main(int, char**, void*);
extern (C) int rt_init();
extern (C) int rt_term();

extern(C) int main(int argc, char** argv)
{
        auto res = _d_run_main(argc, argv, &testmain);
        res = _d_run_main(argc, argv, &testmain);
        return res;
}

int testmain(string[] args)
{
        return 1;
}

Backtrace:



int(char[][]) function).runAll() ()

int(char[][]) function).tryExec(scope void() delegate) ()



Is this the expected behavior?

I guess that the problem is at least here:
https://github.com/dlang/druntime/blob/8fd52019826259dc92ab712f4b37a3f0ea4d8265/src/core/time.d#L2514

Tried with dmd-2.082.0

--
Sep 25 2018