How to track application strange behaviour? - delphi

One of my client has experience strange behavior of my application - on second time it runs - it just closing - no error or anything.
How can I track this kind of "heisenbugs" where I don't have any stack trace or physical access to the remote machine nor I can't recreate the behavior my client is describing?

on second time it runs - it just closing - no error or anything.
an error in a With... Do... Try...Finally...Free... maybe ? At the end it would close the appli instead of freeing the scoped object?

The Windows Debugger Tools provides a DbgSrv service which handles 'second change exceptions' and can generate an extensive report when it detects a selected executable runs but closes under a severe error or suspicious activity.

Related

instruments[34247:1345307] Attempting to set event horizon when core is not engaged, request ignored

I get this error during ui automation and am unable to resolve it.
This stops my automation flow ...
instruments[34247:1345307] Attempting to set event horizon when core
is not engaged, request ignored
In my experience, this message is related to the startup or shutdown of the individual processes that enable UIAutomation; nothing in your javascript code or environment really has an effect on it. It's just a sporadic error that comes from somewhere in Apple's software.
Sometimes it happens at the beginning of the run (in which case your javascript code will never be executed), or at the end of the run (in which case your code has already run). If you are seeing this error at the end of a test run and your code did not fully execute, then the real error is probably happening sometime before this -- you are just seeing Apple's error as well on the test shutdown.

monodroid activity - wrong activity at start up

I have developed a monodroid application with several activities.
Occasionally, the wrong activity is shown first, as opposed to the one with "MainLauncher=true" set.
Also, occasionally I get a dialog stating "Could not determine activity to run because the generated manifest could not be found?
I occasionally see the wrong activity on startup.
I think this generally seems to be when I haven't changed any code and try to restart my application for a second debugging session.
I think what happens in this case, it that Android tries to restart my application on the page/Activity where I last left it. This situation also happens when the app is in general use - so it's good practice to write your code so that the app works in this situation (e.g. using the saved instance state bundle)

"<Program> has stopped working" explanation

Can someone explain me when Windows shows this message?
What do i have to do to stop my Program from throwing this exception?
I have a Delphi Windows Forms Program which throws this message short after doing some SQL operations.
So i do the SQL, everything seems fine at first, but at a random time after that windows is killing it by showing this message...
the intresting thing is, it only occours while debugging.
When i'm not debugging it's running perfectly stable.
EDIT: Using RAD-Studio2009
I dont want to turn off the message completely(Only hint i found by using Google)
i want to stop my program giving windows a Reason to do that.
Windows shows this message when an unhandled exception leaks out of your application. This is a fatal condition. Something very wrong has happened with your application because exceptions should all be caught.
You need to work out what is throwing the exception and why it is not being caught. The very first step is to expand the details of the error dialog and find out which module the fault is occurring in, what the fault is and so on. That should yield some high level clues at the very least.
Most likely the Delphi debugger will not be able to help you for such a fault. You need to configure your system to arrange for a crash dump to be produced by the Windows Error Reporting service. Then you can load up the error report in a tool like WinDbg and try to figure it out.

Debugging Delphi ISAPI Dll on Apache

I have run into a situtation where frequently when debugging a ISAPI Dll (TWebModule) running under Apache I get errors. The caption on the error box is "Debugger Fault Notification" and contained in the message is, among other things:
"c:\program files\Apache\bin\httpd.exe faulted with message......."
When this happens the cpu window pops up, and I have to hit the "OK" button on the error message. I might have to do this 3 - 5 times before program flow continues.
This is happening on my laptop. I have a desktop with the same exact configuration (as far as I know) and I don't have this problem. Both operating systems are XP. So obviously there is some setting or outdated file somewhere.
Also, I have noticed if first run my website when Apache is not in the debugging envrironment it seems not to have this problem. (i.e. start apache in the services, run my web app, stop the service, and then debug it within the Delphi environment).
Any ideas???
While it doesn't directly answer the how to debug using Apache, another alternate debugging technique which works well is to use idDebugger (near the bottom of that page). It will allow you to debug ISAPI DLL's directly from the IDE without having to start/stop services. I now never develop ISAPI DLL's without it.
To avoid this and other problems, I've started xxm. It's an alternative to TWebModule, and uses a separate wrapper to run with IIS, but there's also an Apache, FireFox and IE wrapper! It also uses mixed-HTML-Delphi-source and the development-mode wrappers do the parsing and an auto-compile to give a web-script-like environment.
Also the InternetExplorer plugin works great in the debugger (with iexplore.exe as host application).
Error code 0xC0000008 is Status_Invalid_Handle. That can be thrown by CloseHandle, for example, when you try to close a handle that either was never open or was already closed. The error might not occur when you're running outside the debugger because the API won't throw an exception unless it's being debugged.
If you're getting that exception in code that the debugger doesn't have access to, then the debugger will display the CPU window instead. Look at the call stack to find the place in your code closest to where the exception came from.
It's also possible that it's not occurring in your code at all. Try doing your same debug routine without your module installed. Do you still get errors?

Starting a windows service fails with error 1053

I have a windows service that is failing to start, giving an error "Error 1053: The service did not respond to the start or control request in a timely fashion".
Running the service in my debugger works fine, and if I double click on the the service .exe on the remote machine a console window pops up and continues to run without problem - I can even see log messages showing me that the program is processing everything the way it should be.
The service had been running fine previously, though this is my first time, personally, trying to deploy it with the most recent changes made to the program. I've evaluated those changes and cant figure out how they might cause this problem, particuarly since everything runs fine when not started as a service.
The StartRoutine() method of the service impelmentation is empty, so should be returning in a "timely fashion".
I've checked the event logs on the computer, and it doesn't give any additional information other than it didn't hear back from the service in the 30 second requisite time frame.
Since it works on my machine, and as a double-clicked executable, how would I go about figuring out why it fails as a service?
Oh, and it's .NET 2.0, so it shouldn't be affected by the 1.1 framework bug that exhibited this symptom (http://support.microsoft.com/kb/839174)
The box is a windows server 2003 R2 machine running SP2.
This is a misleading error. It's probably an unhandled exception.
Empty your OnStart() handler then try this in your constructor...
public MainService()
{
InitializeComponent();
try
{
// All your initialization code goes here.
// For instance, my exception was caused by the lack of registry permissions
;
}
catch (Exception ex)
{
EventLog.WriteEntry("Application", ex.ToString(), EventLogEntryType.Error);
}
}
Now check the EventLog on your system for your Application Error.
Could be a number of things and it might help to get a stack trace on the machine exhibiting the problem. There are a number of ways to do this but the point is that you have to see where this is failing in the code.
You can do this with remote debugging, but a simple thing might be to just log to the event logger, or file log if you have that. Literally, putting "WriteLine("At class::function()") throughout portions of the code to see if you've made it there.
This will at least get you looking in the right direction (which ultimately is the code).
Update:
See Microsoft's How to Debug Windows Services article for details in troubleshooting startup problems using WinDbg.
This related question details nice ways to debug services that are written in .NET.
I agree with Scott, the easiest way to find out what's happening is to put some traces in the start-up code (maybe it doesn't even come to your start-up code).
If this doesn't help, you can post your code here so others can take a look.
perhaps lacking some dependence, try this :
- deregister your service
- register again
If fail at register means that lack an module.
If the StartRoutine is empty, you are probably starting it somewhere else.
IIRC you need to fire off a worker thread, and then return from StartRoutine.
One of the problems which may lead to this error is if windows service which needs to be deployed consists of some error i.e it may be simple authorization error or anything as in my case I have referenced some folders and files for logging which were not existing, but when provided the right path of those file and folders it solved my problem.
I ran through every post on this particular subject and none of the responses solved the problem, so I'm adding this response in case this helps someone else. Admittedly this only applies to a new service, not this specific case.
I was writing a File listening service. As a console app, it worked perfectly. When I ran it as a service, I got the same error as above. What I didn't know (and many of the MSDN articles about services conveniently leave out) is that you need to have your class executed from within ServiceBase.Run( YourClassName());. Otherwise, your app executes and immediately terminates and because it terminated, you get the error above even if no error or exception occurred. Here is a link to an article about this. It actually discusses setting up your app for dual use - Console app and service: Create a combo command line / Windows service app
I had that issue and the source of my problem was config file. I edited it in notepad and notepad added one special character which cause service not to run properly because config file was ruined. I saw that special character in notepadd++ and after delete it, service started to run successfully as previous did.
In my case, the correct .NET framework was not installed on the server that I was installing the Windows service on.
One other reason is If you copy the DLL in 'debug' mode to installation folder this issue will come.What you need to do is Run the project in 'Release' mode copy the DLL or directly form Release folder rather than Debug folder,,and copy that DLL in to installation folder,it will work.You can see the reduction in size of DLL ,it will not contain any debug symbols and like that

Resources