Thread overview
[Issue 971] New: No profiling output is generated if the application terminates with exit
Feb 16, 2007
d-bugmail
Feb 16, 2007
d-bugmail
Feb 16, 2007
Sean Kelly
Feb 16, 2007
d-bugmail
Feb 16, 2007
Sean Kelly
Aug 10, 2007
d-bugmail
Aug 10, 2007
d-bugmail
Aug 13, 2007
d-bugmail
February 16, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=971

           Summary: No profiling output is generated if the application
                    terminates with exit
           Product: D
           Version: 1.005
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: david@ferenczi.net


test1.d :
--------------8<-----------------------------------
int main(char[][] args)
{
    return 0;
}
--------------8<-----------------------------------

test2.d:
--------------8<-----------------------------------
static private import std.c.stdlib: exit;

int main(char[][] args)
{
    exit(0);
    return 0;
}
--------------8<-----------------------------------

dmd test1.d  -profile
./test1

--> trace.def and trace.log are generated

dmd test1.d  -profile
./test2

--> no output generated


-- 

February 16, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=971





------- Comment #1 from david@ferenczi.net  2007-02-16 15:40 -------
In the 2nd case test2.d will be compiled, of course.

dmd test2.d  -profile
./test2

> dmd test1.d  -profile
> ./test2
> 
> --> no output generated
> 


-- 

February 16, 2007
No output will be generated if the application terminates from an unhandled exception either.  But I think this is correct behavior.  If the application is terminated abruptly then it should be expected that unwinding code will not be executed.
February 16, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=971





------- Comment #3 from david@ferenczi.net  2007-02-16 16:31 -------
It may have been just a bad practice of mine to use the exit function also for normal terminating. The question is, if it's really a misuse, or e.g. exit(EXIT_SUCCESS) should be treated as normal termination.

(Nevertheless I cahnged my code, so it doesn't contain any exit calls.)


-- 

February 16, 2007
d-bugmail@puremagic.com wrote:
>
> ------- Comment #3 from david@ferenczi.net  2007-02-16 16:31 -------
> It may have been just a bad practice of mine to use the exit function also for
> normal terminating. The question is, if it's really a misuse, or e.g. exit(EXIT_SUCCESS) should be treated as normal termination.

That's a good question.  A normal termination in C terms is not a normal termination in D terms, but one could argue that the D runtime should handle this case anyway.  I think it would be easy enough to do with atexit() however.
August 10, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=971





------- Comment #5 from wbaxter@gmail.com  2007-08-09 21:43 -------
Ok, so how *does* one exit from deep within a program in a manner that will still generate profile info?

The only thing I could think of was to put an exception handler around the main loop, and then throw an exception when I want to stop execution.

Is that the best option?


-- 

August 10, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=971





------- Comment #6 from sean@f4.ca  2007-08-10 10:58 -------
That's the most straightforward approach.  Unfortunately, it only works when done in the main program thread.  An alternate, evil approach would be to suspend all threads, manually call the runtime cleanup routines, and then call C exit().  The safest would probably be for the runtime to register its cleanup routines using _atexit() or the equivalent so C exit() can be called.


-- 

August 13, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=971





------- Comment #7 from bugzilla@digitalmars.com  2007-08-13 00:00 -------
You can call trace_term() in internal/trace.d to send out the output. I'll make
it extern(C) in the next update to make this easier.

The profiler won't work with multithreaded code anyway.


-- 

October 29, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=971


Justin Spahr-Summers <Justin.SpahrSummers@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Justin.SpahrSummers@gmail.c
                   |                            |om
            Version|1.005                       |2.035
         OS/Version|Linux                       |Windows


--- Comment #8 from Justin Spahr-Summers <Justin.SpahrSummers@gmail.com> 2009-10-29 15:12:09 CDT ---
I don't know if this issue ever got resolved, but now it's cropping up with a "void main" too, even through a clean return. "int main" does not share the problem.

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