Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7620927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:04:08+00:00 2026-05-31T04:04:08+00:00

I am working onsite with a client, and I am trying to help them

  • 0

I am working onsite with a client, and I am trying to help them with a complicated problem. I am hoping that there is a tool or feature in Delphi that we can use to peer into the inner workings to help us locate the problem.

Here is a high level overview of the problem we are dealing with. This is a commercial application that is currently deployed in Delphi 5. Over the past year the application has been migrated to Delphi XE. The migration is almost complete, but there are some serious errors that are being encountered.

The application itself is very large, with hundreds of units and many third-party and custom components. In one specific situation that we are encountering, the main form is created and then the application is terminated before that main form is displayed. The result is a crash that occurs during this termination, as units are being finalized.

The debugger is breaking in the RaiseException function of kernel32, which is called by NotifyNonDelphiException. We tried to set a non-breaking breakpoint that logs the call stack from within NotifyNonDelphiException, but that does not give us anything useful. The call stack contains only methods that handled the exception, and that is RtlRaiseStatus and KUserExceptionDispatcher.

How do we identify the code that throws the original exception that is being handled by NotifyNonDelphiException?


edit: Here are two images captured following one instance of the exception. The first one is the raised exception, and the second depicts the CPU window after the exception dialog box is closed.

Access violation upon exit

CPU window upon closing the exception dialog box

New Edit:

It has been more than a week since I posted this question, and I am impressed with the various answers. Some of the comments to the initial question were most valuable, but some of the answers themselves are very informative.

My visit to that client is over, and I will ask them to consider the answers that have been posted here. While we were not able to track down the actual source of the error, the cause of the error was more than obvious. Many years of tweeking the user interface without a serious refactoring left the application with an unstable log in process. When the log in was canceled by the user, the main form was in a partial state of initialization. When this process was not permitted to run its course, which was what happened when the user aborted log in, very serious finalization issues were present.

The company has purchased AQTime Pro to help identify future problems, but a refactoring of the login process is called for, and will solve the problem in the long run.

At one point I considered removing this question, but I have opted to keep it posted, since I believe that others will find the many excellent suggestions that were posted informative.

For the time being, I am accepting @Deltics answer, since I hate leaving a question without an answer. However, I ask viewers of this question to also consider all of the other answers and comments, and they are equally valuable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:04:09+00:00Added an answer on May 31, 2026 at 4:04 am

    Exceptions should never be allowed to “escape” from finalization (or initialization) sections for precisely this reason.

    With very few exceptions [sic], any code in a finalization section should be enclosed in a try..except. What you do when you get an exception is up to you, but at the very least a call to OutputDebugString() will give you information when debugging and give you a point on which to set a breakpoint that will only cause a break when an actual exception has occurred.

    finalization
      try
        // Perform finalization processing here
    
      except
        on e: Exception do
          OutputDebugString('%s: $s in unit %s', [e.ClassName, e.Message, 'MyUnitName']);
      end;
    end.
    

    NOTE: The OutputDebugString() call in this code is to my own “string friendly”, wrapper around the function in the Windows unit, extended to accept args.

    Since you presumably don’t have such exception handling in your finalization sections, this will involve putting them in place before you can proceed. However, this exercise will improve the quality of your code overall, and make diagnosing any similar problems in the future that much easier (who’s to say that once you have identified and fixed your current exception, that some other finalization exception will not raise it’s ugly head?).

    Also, the process of applying this exception handling will give you an opportunity to review each finalization section and determine whether it cannot be handled differently, with a view to eliminating as many finalization sections as possible.

    This should not be considered an “unnecessary overhead” or a “waste of time” but an essential piece of housekeeping to bring your code quality up to an acceptable standard.

    An Alternative Approach

    An alternative approach is to manage your own list of finalization procedures, as we had to do before finalization sections were introduced. i.e. in the initialization section of a unit that current has finalization, remove the current finalization code into a parameterless procedure and register that procedure with a “finalization manager”.

    Then, in your application, invoke the “finalization manager” at an appropriate time during application shutdown, to perform your finalization before any actual unit finalization takes place. This ensures that your finalization procedures are performed with the runtime exception handler still in place.

    This also presents the opportunity for providing a more sophisticated “finalization manager”, with mechanisms to ensure that finalization procedures are performed in a specific, determined order (if required). This capability depends on how you implement your own finalization manager, naturally.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on a bunch of forms at the moment and I'm finding that I
Working on a website that has Employee and Branch entities, using a database table
Working on an irc client in Adobe AIR in JavaScript, and thinking about logging.
Working on a movie website and would love to find an API that I
Working on a page with multiple sections. at the very top there is a
Working on joining up two legacy DB systems into new database where I can
While working on ASP.NET MVC 2 web site I faced to the following problem.
i'm working on site like http://artofflightmovie.com/ , i know how to achieve that effect
I've been working on a site that has a lot of PHP/Smarty involved, I've
Folks, I'm trying to track down an intermittant bug that's showing up on site.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.