Exception only caught in Delphi IDE, but not in the EXE

delphi package - automated exception handling
Post Reply
caps
Posts: 8
Joined: Mon Oct 26, 2020 3:32 pm

Exception only caught in Delphi IDE, but not in the EXE

Post by caps »

Hi,

I've searched this board and found this topic 2 times, but the solutions don't apply for me. Therefore I came to the point of posting it again hoping I can find a way to solve the issue.

Conditions
Delphi version 5.0
madExcept version 4.0.21

I've created a blank application with nothing more than a button which does the following to create an exception:

Code: Select all

integer(nil^) := 0;
Now when I compile the program with disabled madExcept the exe file size is about 200kB. When I enable madExcept and compile the exe file size is about 700kB so I suppose the exe is successfully patched by madExcept.

Issue
- When I start the compiled exe and click on the button I get a standard Windows error message saying "[...] write of address 00000000". Nothing else.
- When I start the program within the Delphi Environment with [F9] and press the button following happens:
1) I get a Delphi exception message and the program halts on the position of the assignment as above.
2) I press [F9] again.
3) The program form apperars again (goes on running) and the desired madExcept error message appears with the bug report.

So what can be wrong with the compiled exe file?

Furtherly
According to hints from other posts I have already attached the file madExceptWizard.txt from my desktop which I emptied and then compiled the project with madExcept enabled (I had to rename it to .zip to be able to upload it here :confused: )


Thanks in advance for any help!

Best regards
Caps
Attachments
madExceptWizard.zip
actually a txt file
(16.14 KiB) Downloaded 151 times
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Exception only caught in Delphi IDE, but not in the EXE

Post by madshi »

The log file doesn't seem to indicate that madExcept was notified that the compilation has succeeded. Do you have the Delphi 5 update packs installed? It seems really weird, though, that it would work when started within the IDE but not when started outside. I can't recall this being reported before.

In any case, madExcept 4 is outdated. Have you tried madExcept 5?
caps
Posts: 8
Joined: Mon Oct 26, 2020 3:32 pm

Re: Exception only caught in Delphi IDE, but not in the EXE

Post by caps »

Thanks for the immediate answer!
No, I've not yet tried madExcept 5, but will immediately try it.
So I should deinstall madExcept 4 and remove any remainders of it in the file system first and then install mE5, or can I just install it over the previous version?
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Exception only caught in Delphi IDE, but not in the EXE

Post by madshi »

You should be able to just install it over madExcept 4.
caps
Posts: 8
Joined: Mon Oct 26, 2020 3:32 pm

Re: Exception only caught in Delphi IDE, but not in the EXE

Post by caps »

Hm,

unfortunately it did not help. I've installed madExcept 5, deleted everything in the project except from the .dpr, .pas and .dfm and recompiled the project. Same problem.
I've attached madExceptWizard.zip (txt) again in this post.

:(
Attachments
madExceptWizard.zip
(19.57 KiB) Downloaded 144 times
caps
Posts: 8
Joined: Mon Oct 26, 2020 3:32 pm

Re: Exception only caught in Delphi IDE, but not in the EXE

Post by caps »

Interesting:

For some reason I started the program within the IDE, and afterwards I started the compiled exe.
In this case the mE message window appeared also in the compiled exe.
BUT:
When I went back to Delphi, made some settings in the mail area of mE and recompiled the exe, then the compiled exe showed the standard Windows box again, instead of the mE window... (?)
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Exception only caught in Delphi IDE, but not in the EXE

Post by madshi »

So starting the EXE inside of the IDE makes it work outside? Can you reproduce that?
caps
Posts: 8
Joined: Mon Oct 26, 2020 3:32 pm

Re: Exception only caught in Delphi IDE, but not in the EXE

Post by caps »

Ideed it seem so.
I did the following:

1.) Disable madExcept for the project.
2.) Save the project
3.) Compile the project (exe file about 200kB).
4.) Start the compiled exe and press the button.
Result: Standard Windows box

5.) Enable madExcept for the project.
6.) Save the project.
7.) Compile the project (exe file about 700kB).
8.) Start the compiled exe and press the button.
Result: Standard Windows box

9.) Start the project within Delphi IDE and press the button.
Result: Delphi exception
10.) Press [F9]
Result: Program goes on running AND madExcept window appears (desired behaviour).

11.) Press "continue application" and quit the program by clicking [x].
12.) Start the compiled exe and press the button.
Result: madExcept window appears (desired behaviour).

:o

D'you have an idea?
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Exception only caught in Delphi IDE, but not in the EXE

Post by madshi »

When not running the program within the IDE, you're still compiling it within the IDE? Or are you compiling it a different way (e.g. command line, or some other tool)?

What happens if you enable madExcept, save the project, then close the project, reopen the project, compile. Does it work then?
caps
Posts: 8
Joined: Mon Oct 26, 2020 3:32 pm

Re: Exception only caught in Delphi IDE, but not in the EXE

Post by caps »

I compile the project always in the IDE, no command line tool or anything.

I've tried the steps as you suggested:

1) Enable madExcept
2) Save the project.
3) Close the project (not Delphi)
4) Reopen the project
5) Compile the project
6) Start the compiled exe file (700kB) and press the button.
Result: unfortunately standard Windows box appears
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Exception only caught in Delphi IDE, but not in the EXE

Post by madshi »

This all makes sense only if running the EXE inside of the IDE actually results in another recompile. Does that happen?

Do you have the Delphi 5 Update Pack installed?
caps
Posts: 8
Joined: Mon Oct 26, 2020 3:32 pm

Re: Exception only caught in Delphi IDE, but not in the EXE

Post by caps »

Goddamnit! :D

I noticed that the size of the compiled exe changes after I pressed the "OK"-Button in Delphi which tells me that the compilation has been done successfully.
Hm... before I obviously just let that notification box open for me to know that the project had compiled.
Now it seems to work the way it should.

Well... in that notification box of Delphi should not be written "Ready. Compile done." - that reads as "Ready. Compile done."
Otherwise it should be written as "Ready. Compile done, but wait: in case some post compilation steps are still to be done you'd better press the OK button, or your program will not work as desired." :wink:

:redBalloon:

Thanks for your help, I think this issue is fixed.
It also seems to work in my "real" application where I first stumbled over it.

Greeties!
Caps
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Exception only caught in Delphi IDE, but not in the EXE

Post by madshi »

I've configured Delphi to auto-close that box on success... :D
caps
Posts: 8
Joined: Mon Oct 26, 2020 3:32 pm

Re: Exception only caught in Delphi IDE, but not in the EXE

Post by caps »

Good idea, I should do that too... :-)
Post Reply