www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 971] New: No profiling output is generated if the application terminates with exit

reply d-bugmail puremagic.com writes:
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


-- 
Feb 16 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=971






In the 2nd case test2.d will be compiled, of course.

dmd test2.d  -profile
./test2

 dmd test1.d  -profile
 ./test2
 
 --> no output generated
 
--
Feb 16 2007
prev sibling next sibling parent Sean Kelly <sean f4.ca> writes:
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.
Feb 16 2007
prev sibling next sibling parent reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=971






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.)


-- 
Feb 16 2007
parent Sean Kelly <sean f4.ca> writes:
d-bugmail puremagic.com wrote:

 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.
Feb 16 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=971






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?


-- 
Aug 09 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=971






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.


-- 
Aug 10 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=971






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.


-- 
Aug 12 2007
prev sibling parent d-bugmail puremagic.com writes:
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



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: -------
Oct 29 2009