Unable to update "MESettings" on Runtime

delphi package - automated exception handling
Post Reply
erikson250
Posts: 7
Joined: Mon May 15, 2017 3:37 pm

Unable to update "MESettings" on Runtime

Post by erikson250 »

Hi

I've inherited a Delphi2009 project which uses MadExcept 3.0k and mostly of the functionalities used from MadExcept is dealing with unhandled exception, creating bug reports whenever they happen.

The thing is that we're intending to use more features from MadExcept, where one of them is mailing bug reports and start handling exceptions in the new code using the mad except exception handler. In the other hand, for the legacy code, we're intending to catch them all through a exception hook.

My problem is when I try to set values to "MESettings" class, the values are not properly set... Looking into the madExcept.pas I realized that the values are only set when the property "FValid"(TIMESettings) is true. However, I don't know why in this project in specific I can set these settings since I can define them normally in another brand new test project. Other than that, I can't debug madExcept, even having the library path correctly set(or even adding the madExcept source file in the project itself).

So, can anyone explain why it is happening or at least give me clues?

Thanks in advance.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Unable to update "MESettings" on Runtime

Post by madshi »

Does MESettings().IsValid() return FALSE? Or was that just a wild guess that it might be invalid? Usually MESettings() is only invalid if you haven't activated madExcept in the madExcept settings. You do compile in the IDE, or do you compile with command line, MSBuild or other build tools?

In order to debug madExcept.pas, you need to copy madExcept.pas and mad.inc into your project folder. Then make sure that "{$D+}{$L+}" are set to + in the mad.inc file.
erikson250
Posts: 7
Joined: Mon May 15, 2017 3:37 pm

Re: Unable to update "MESettings" on Runtime

Post by erikson250 »

Hi

Thanks for the prompt reply.

During the runtime, I check the value of "MESettings.IsValid" and the return is false. In my other project used to play around with mad except capabilities it works fine and the result of "MESettings.IsValid" is true. I check the madexcept settings and it's activated in both projects. Besides the problematic project be way more complex than the test project, the executable output path is different than the current source folders.
Note: The .mes files from both projects are identical.

Update #1
The "function GetMeSettingsRes(module: dword) : dword;" is returning 0.
Callstack:
madExcept.GetMeSettingsRes(4194304)
madExcept.ReferenceMeSettingsModule(4194304)
madExcept.TIMESettings.Create(4194304,True)
madExcept.MESettings(4194304)
madExcept.Init
madExcept.madExcept
System.InitUnits

The compilation problem have been fixed by setting the conditional define debugMadExcept(DEBUG;madExcept;debugMadExcept). Thanks for the tip!

Do you have any other suggestions regarding the "MESettings.IsValid" issue?
Last edited by erikson250 on Thu May 18, 2017 1:29 pm, edited 1 time in total.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Unable to update "MESettings" on Runtime

Post by madshi »

Please try this:

1) Create an empty file "madExceptWizard.txt" on your desktop.
2) Recompile the problematic project.
3) Attach the text file here.
erikson250
Posts: 7
Joined: Mon May 15, 2017 3:37 pm

Re: Unable to update "MESettings" on Runtime

Post by erikson250 »

Attached.

I hope the changes I made to hide sensitive info do not interfere in the troubleshoot process.

Note: Had to create the file in C:\.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Unable to update "MESettings" on Runtime

Post by madshi »

Can't seem to find the attachment?
erikson250
Posts: 7
Joined: Mon May 15, 2017 3:37 pm

Re: Unable to update "MESettings" on Runtime

Post by erikson250 »

I attached twice... nevermind, here it is:

10:30:55-797 AfterCompile event, succeeded: +, isCodeInsight: -
10:30:55-802 [0] module "C:\<edited>\src\madExcept.pas"
10:30:55-803 [1] module "C:\Rep2009\madCollection\madExcept\Sources\madExceptPatcher.pas"
10:30:55-803 [2] module "c:\program files (x86)\codegear\rad studio\6.0\SOURCE\WIN32\RTL\SYS\SysInit.pas"
10:30:55-803 [3] module "default.htm"
10:30:55-804 [4] project group
10:30:55-804 [0] project "C:\<edited>\src\myProject.dproj"; moduleEditor[0]: "C:\<edited>\src\myProject.dpr"
10:30:55-805 AfterCompile, succeeded: +
10:30:55-805 root: "C:\<edited>\myProject"
10:30:55-805 isDpk: -
10:30:55-806 binary: "C:\myProject\myProject.exe"
10:30:55-806 map file: "C:\myProject\myProject.map"
10:30:55-806 PatchBinary, compileSucceeded: +, binary: "C:\myProject\myProject.exe", root: "C:\<edited>\src\myProject"
10:30:56-359 map file successfully loaded/parsed
10:30:56-359 binary successfully opened
10:30:56-499 append map file to binary
10:30:56-499 map file is not yet appended
10:30:58-290 append map file now
10:30:58-291 Info: map file appended
10:30:58-298 PatchBinary done
10:30:58-299 AfterCompile done
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Unable to update "MESettings" on Runtime

Post by madshi »

And the path "C:\myProject\myProject.exe" is correct? If you open that EXE file with e.g. Resource Hacker or PEBrowsePro (or any other tool that lists PE resources), is there a resource named "MAD\EXCEPT" in the exe file?
erikson250
Posts: 7
Joined: Mon May 15, 2017 3:37 pm

Re: Unable to update "MESettings" on Runtime

Post by erikson250 »

The paths are correct.

Checked both applications with resource hacker and the problematic project indeed does not have the resource "TMADEXCEPT" and the test project have it.

Update #1:
Checked one executable generated by the continuous integration environment and the resource was there... However this environment is windows XP and mine is win7.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Unable to update "MESettings" on Runtime

Post by madshi »

There's something fishy going on. The log claims the EXE was patched, but the MAD\EXCEPT resource is not there. Which means that either the log is lying, which is not very probable, or the path is not correct, or "somebody" replaced the patched file with a different version. Do you have any post build events running? Maybe one of those is responsible?
erikson250
Posts: 7
Joined: Mon May 15, 2017 3:37 pm

Re: Unable to update "MESettings" on Runtime

Post by erikson250 »

Tell me about it...

So, if I patch it manually(madExceptPatch.exe) I'm able to make the resource part of the executable.

I'm going to take a look in my IDE to see if there's something wrong...

Thanks for the help so far
erikson250
Posts: 7
Joined: Mon May 15, 2017 3:37 pm

Re: Unable to update "MESettings" on Runtime

Post by erikson250 »

Finally found the issue. I found a very similar thread: madExcept not "enabling" for my project.

In this thread the user "stuartclennet" states that when turning off the linker->debug information the mad except started being patched correctly. The same happened here (:

Thanks for the help and sorry for not researching better before post a new thread.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Unable to update "MESettings" on Runtime

Post by madshi »

That's very weird. Not sure why that happened. But I'm glad that you found it!
Post Reply