Thread overview
[Issue 5215] New: Crash with empty program
Nov 14, 2010
Don
Jan 20, 2012
Walter Bright
Jan 20, 2012
Brad Roberts
Jan 20, 2012
Andrej Mitrovic
Jan 20, 2012
Walter Bright
November 13, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5215

           Summary: Crash with empty program
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Optlink
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2010-11-13 14:46:08 PST ---
This simple wrong D2 program generates expected linker errors and then an unexpected crash on Windows:


void main();

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 14, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5215


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clugdbug@yahoo.com.au


--- Comment #1 from Don <clugdbug@yahoo.com.au> 2010-11-13 18:01:25 PST ---
(In reply to comment #0)
> This simple wrong D2 program generates expected linker errors and then an unexpected crash on Windows:

> void main();

What do you mean, 'unexpected'? It complains that there's no main(). Passing an
empty file does exactly the same thing.
(The annoying thing is that it makes an exe anyway, even though the exe is
corrupt).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 14, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5215



--- Comment #2 from bearophile_hugs@eml.cc 2010-11-13 18:46:45 PST ---
(In reply to comment #1)

> What do you mean, 'unexpected'? It complains that there's no main(). Passing an
> empty file does exactly the same thing.
> (The annoying thing is that it makes an exe anyway, even though the exe is
> corrupt).

You are right, sorry. The crash is not caused by the compiler/linker, but by the corrupt exe.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5215


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |WONTFIX


--- Comment #3 from Walter Bright <bugzilla@digitalmars.com> 2012-01-20 02:12:34 PST ---
The linker is supposed to create an exe file, even if there are errors. This is handy for some special purposes.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5215


Brad Roberts <braddr@puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |braddr@puremagic.com
         Resolution|WONTFIX                     |


--- Comment #4 from Brad Roberts <braddr@puremagic.com> 2012-01-20 10:19:27 PST ---
What circumstances?  I don't have a lot of experience with windows, but binutils ld doesn't leave broken turds when linking fails like that.  I can see having a linker option to force it to leave the output alone on error, but not having that as the default behavior.  Would you treat dmd leaving a .obj file around if there are syntax errors in the .d being built?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5215


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

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


--- Comment #5 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-01-20 10:31:54 PST ---
Optlink has a /DELEXECUTABLE flag for deleting the exe if there are linker errors, but it doesn't work (I assume because optlink creates warnings instead of errors for OPs code).

Additionally optlink creates executables even if you don't pass anything to it, e.g.:

$ link.exe
creates .exe

The linker gives you warnings and creates a `.exe` file. Pretty stupid behavior if you ask me. Every modern console app would display a list of arguments you can pass to it, or a sane warning instead of "OPTLINK : Warning 134: No Start Address" when you didn't pass a single file to it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 20, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=5215



--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2012-01-20 12:47:06 PST ---
The special purposes are when parts of your program are missing, but you want to link and run the rest of it.

I'm not sure why /delexecutable is not working, though.

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